Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress The WordPress Template Hierarchy Custom Post Type Templates in WordPress Custom Post Type Templates Continued

Jaime Rios
Jaime Rios
Courses Plus Student 21,100 Points

Displaying the most recent element for each custom post-type.

What would I need to display the most recent element for each custom post-type on front-page.php.

I know how to make it display one for each custom post-type, but how does it work for the most recent of each post-type?

1 Answer

Garrett Sanderson
Garrett Sanderson
12,735 Points

Hi Jaimie,

What you have to do is call for the different post types in your $args array that you pass into the WP_Query.

You will just need to change up your code a bit for the post type item in the array. You need to add an array of your post types that you want to call.


$args = array( 
      'post_type' => array( 'post', 'report', 'opinion', 'bookmark' )