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

Jiaqi Li
Jiaqi Li
6,198 Points

After I add a new page. there is no "Template" choice before I publish, is there something wrong?

I have followed the video and copy the "art.php", "single-art.php", "art-content.php". It may not take effects when I add a new page, there is no "Template" choice before I publish, is there something wrong?

6 Answers

Jacobus Hindson
Jacobus Hindson
14,429 Points

Try changing the name of the file to page-art.php

Jacobus Hindson
Jacobus Hindson
14,429 Points

Yes your templates and theme variations should always be named x-y.php. For example:

Static Page = page.php - Page Template = page-art.php Single Blog Post = single.php but a Single Portfolio would be single-portfolio.php

This is true for sidebar, content, archive etc.

Check out the Wordpress Hierarchy for more info..there is also a Treehouse course on the same subject but I would work up to that.

Jacobus Hindson
Jacobus Hindson
14,429 Points

Hi Jiaqi,

Did you put the comment for Template Name; <name here> in the top of your template file?

For example.

/* Template Name: Art Page */

Jiaqi Li
Jiaqi Li
6,198 Points

Hi, Jacobus

Yes. I included in the art.php

<?php /**

  • Template Name: Art Page */

get_header(); ?> ......

Do I need to add it to another php file? I make every file following the course. Just can't see the choice.

Thanks

Jiaqi

Jiaqi Li
Jiaqi Li
6,198 Points

Cool! After I changed the file name, the "Template" attribute came out. Thanks very much, Jacobus! But why not page.php, is it contradictory? So when I make a custom page, do I need to name it with a suffix every time?

Jiaqi Li
Jiaqi Li
6,198 Points

Now I'm in the middle of the course of WordPress Theme Development, and I need to learn more about Wordpress Hierarchy and php. Thanks again!