Wordpress WP Query + Custom Post + Custom Fields + Order By Compound

Asked

Viewed 19 times

1

Good afternoon, I searched a lot about it, summarizing: I need a query that brings the post (custom post documents, (title and publication date), in addition to custom_post (Document that is a file, Unit that is a Select and Type that is another Select)

So far I’ve got this code, but it’s not working:

    $args = array (
        'post_type'              => array( 'documentos' ),
        'post_status'            => array( 'publish' ),
        'nopaging'               => true,
        'orderby'        => array( 'unidade' => 'ASC', 'tipo' => 'ASC', 'post_date' => 'DESC' )
        'meta_key' => 'unidade'
    );

    $services = new WP_Query( $args );

    if ( $services->have_posts() ) {
        while ( $services->have_posts() ) {
            $services->the_post();
            // do something
        }
    } else {
        // no posts found
    }

// Restore original Post Data
wp_reset_postdata();

This query is not working yet... I searched a lot, but it has some detail that I missed...

  • No one can help?

BS.: The error that is giving is the 500, I am doing on a separate page

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.