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 How to Make a Website with WordPress Custom Post Types and Fields in WordPress Custom Post Type Templates

Is there a benefit to doing it this way (as a page template), rather than as a post type archive (WordPress template)?

So, in his demo, Zac creates an art.php file, sets it as a page template and then manually creates a page to assign that template to.

However, I know that you can also create a WordPress template for the custom post type "art" (archive-art.php), bypassing the need for WP_Query, and customise that template to your needs, as well.

What's the benefit of doing it Zac's way? Why this way as opposed to the other?

Are there benefits to SEO (I know you can set Yoast fields manually using a page template, but according to Yoast's own website there are benefits to having post type archives/category archives as well).

Which way is better? Or are they much of a muchness?

1 Answer

It depends on what you want. Do you want an archive page, or a page? Its better to use {$slug}.php as a page.php file because the archive.php page is not designed to be a single page. If you want to display all your posts then archive is the way to go, if not then page.php is the correct approach to creating themes.

Good answer!

So really it comes down to how many posts you want/need to show? If it's just the one page then go for {$slug}.php - if it's a full archive (probably with pagination) then go for an archive?