Custom WP_Query order by post_meta and (author) user_meta

WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently.

How to do it? Just make multiple refferences, here is one way to do that.

$args = array(
    'orderby' = > array(
        'title' => 'ASC',
        'date' => 'DESC',
    )
);

Learn more here…

But only since WordPress 4.2 it is possible to do this with meta values. Have a look at this post.

Leave a Comment