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 trialAdam Adam
Courses Plus Student 5,156 PointsAre the art.php, content-art.php and single-art.php scripts created automatically or do we need to create them manually?
Are the art.php, content-art.php and single-art.php scripts created automatically when we create custom post types and custim post fields, or do we need to create them manually?
3 Answers
Britton Zirkle
Courses Plus Student 15,005 Pointsdid I miss something or was none of this covered in the lessons? I saw creating the custom post type and custom fields and then creating some examples, then we go to the next video and are told that we have a few new files - art.php, page-art.php, single-art.php, etc.
Seems to me that in creating custom post types that covering how to make the associated files would be kind of important. looking at the template hirearchy isnt as much help as Zac Gordon explaining where the files came from and how they are created.
Lucas Santos
19,315 PointsAll files are created manually. The naming convention of the files are what references to your custom post type.
Some examples of files that would display your art custom post type in the appropriate format: page-art.php, art.php, single-art.php, archive-art.php and so on.
Adam Adam
Courses Plus Student 5,156 PointsDid I understand correctly - when naming the files, I have to follow the strict convention ie. I have to name the files page-art.php, art.php, single-art.php, archive-art.php and so on...?
Lucas Santos
19,315 PointsYes like if you have a page called "Art" and you want to customize that specific page with your custom post type. But if you just want to use your custom post type in what ever page I would use a custom WP_Query for that with a custom page template. I really suggest you look into 3 things that will greatly give you better understanding.
The Wordpress Template Hierarchy so that you can understand what files control what.
Custom Page Templates So you can keep your files more organized and a better way of making different pages
And Wordpress Custom Queries Look into WP_Query so you know how to pull in and use custom post types anywhere.
Those are really thing you want to take time and look into. But ultimately I would go look at the "Wordpress Theme Development" course here at Treehouse so you can get a better understanding of all of those things.
Wenya Chang
1,548 PointsWenya Chang
1,548 PointsI am stuck here too.