0

Looking for a way to loop through multiple custom post types and get the 4 most recent posts.

I have the below but doesn't quite work as if you 2 posts of the same post type, it'll show the most recent rather than showing most recent of ALL custom posts.

$args = array('post_type' => array('cs_trainee', 'cs_graduates', 'cs_pros', 'sd_trainee', 'sd_graduates'), 'posts_per_page' => 4, 'orderby' => 'menu_order', 'order' => 'ASC');
$careers = new WP_Query( $args );

Thanks

1 Answer 1

2

Just change the query_posts parameters a bit....

query_posts( array(
 'post_type' => array( 'post', 'report', 'opinion', bookmark' ),
 'cat' => 3,
 'orderby' => 'date',
 'order' => 'DESC',
 'showposts' => 5 )
 );

That should take care of it for you.

Sign up to request clarification or add additional context in comments.

2 Comments

This worked great however the orderby and order doesn't seem to do anything. Trying to order by post date and in DESC order but makes no difference - do you know why?
I have modified query_posts so you can try this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.