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

mamoderawat
mamoderawat
7,481 Points

The PHP files and code that allow page template and custom posts to appear on new page

Just to confirm, the new PHP files that he copied over to his child theme, were not automatically created when he created and published his custom post and custom fields. To be able to create a new page and set it as a template that displays your custom posts etc you have to enter the PHP code yourself? Because its not clear whether he was just showing the pages to help understand the how he works, or what needs to be done. Either way not well explained from the perspective of someone who isn't downloading the files and just following along and working on WP site the same time.

1 Answer

Nope. You have to add your custom .php template files yourself by hand. Setting up a custom post type either by registering it manually in functions.php or by using a plugin (which essentially does the same), only ads the functionality of custom post types in the WordPress backend. You'll be able to add new custom posts and edit them in the admin area of WordPress. To view your custom posts on the frontend you have to create your own custom template and add a custom loop that loops through your custom post type. For this you have to be able to write and understand PHP code and know the WordPress functions needed.