0

I am trying to query my custom post types. I can display both of them with this code:

'post_type'=> array('map','item')

But I don't want them to mix. I want "map" to display before "item".

Please help!

0

Since version 4.0 is available 'type' option for 'orderby' argument in WP_Query.

Also, thanks to the more powerful ORDER BY in WordPress 4.0 you can control how posts of a post type are ordered.

Example (untested):

$q = new WP_Query(array(
    'post_type' => array('map','item'),
    'orderby'   => array(
       'type'   => 'DESC',
       'title'  => 'ASC'
    )
));
2
  • Thank you, this worked! I had to add remove_all_filters('posts_orderby'); before it in my case! Jan 10 '15 at 22:45
  • Glad it worked. Please mark the answer as accepted if it was right solution for you.
    – gmazzap
    Jan 10 '15 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.