Multiple orderby values in WP_Query

I’m trying to come up with a query to sort by multiple orderby values. Here’s what I have so far:

    $query=new WP_Query(array(
            'post_status'=>array('publish', 'pending', 'future'),

I’m trying to query a custom post type, and within that post type, query a meta value.

Then, I’d like to first sort by menu_order ascending, then by a custom meta value wcu_lastname ascending. However, the orderby value didn’t seem to be able to take an array.

How can I order the query using multiple orderby values?


how can we put multiple order value for the fields?
I was wondering the same question and I found this :

In 4.0, you can now pass an array to WP_Query as the value for

The syntax looks like:

$q = new WP_Query( array( 
    'orderby' => array( 
       'title'      => 'DESC', 
       'menu_order' => 'ASC' 

Have a look here for more details :

Leave a Comment