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

Elizabeth Tucker
Elizabeth Tucker
394 Points

I can't find php files needed to create a template

I have created a custom post type and related fields, but I can't find the php files I need to create a template.

5 Answers

Elizabeth Tucker
Elizabeth Tucker
394 Points

Basically one video ends after the custom field plugins have been installed and the custom posts created, and the next video Zac immediately talks about the php files that were created as a result of these actions, but I have no idea where those are or how to retrieve them. In the video it looks like he's pulling them from the local server, but it's unclear, in addition to the fact that that doesn't make a whole lot of sense. Another user asked the same question, so I know I'm not (that) crazy, but I'm obviously missing something. I'll figure it out eventually. Thanks for the response!

Eric Mayfield
Eric Mayfield
3,312 Points

This action doesn't create any custom files for you. You have to create the custom files yourself. All of his files are included to download. So you can download those files directly from the same page as the video. Those files will go under your theme's directory.

Brian Goldstein
Brian Goldstein
19,419 Points

Zac literally walks you through that. Please rewatch the video

Elizabeth Tucker
Elizabeth Tucker
394 Points

Oh hey, thanks! It never occurred to me to rewatch the video multiple times before posing the question to internet strangers. I'll keep that in mind for next time. Enjoy your day!

Brian Goldstein
Brian Goldstein
19,419 Points

It really was not a snarky comment. Trust me, very few people get any of this on the first try. A general rule here is that the videos cover everything you need to get that task done. When in doubt, they are the most specific resource.

The wp codex (while intimidating) is also the first, best, and last resource on all things WordPress. CSS tricks is another solid resource for a lot of this information too.

Eric Mayfield
Eric Mayfield
3,312 Points

What do you mean you can't find the files. Any and all theme files will be located under /wp-content/themes/your_theme_name/ So if you create a template file for your header you should have a file created called /wp-content/themes/your_theme_name/header.php

For your custom post type template files you would use something like this:

Say you have a custom post type of artists. Well your main page for displaying all artists would be artists.php. For each individual artist you create it would be like single-artist.php.

Here is a nifty chart you can use: https://codex.wordpress.org/images/1/18/Template_Hierarchy.png

Elizabeth Tucker
Elizabeth Tucker
394 Points

That's exactly what I was missing. Thank you!!

Eric Mayfield
Eric Mayfield
3,312 Points

Glad to be able to help. :)