Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Jaime Rios
PLUS
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.

<?php

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

?>