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 trialSam Easterling
10,216 PointsPage templates for static pages?
If I had a small site with a few static pages I could: 1) Recreate the html pages as php pages and just make each page its on template. (ex) about.html would be page-about.php with a php block containing "Template Name: About Page. Select the About Page template as the About page's template.
2) Use a template with a php block containing "Template Name: Static Page. (ex) use a page.php template, select Static Page as the template and paste the html content into page's content area.
Is there a best practice or a better way?
4 Answers
Jaco Burger
20,807 PointsI see, okay, I suggest you do the Wordpress template hierarchy course, or have a look at this page: http://wphierarchy.com That page helps a lot.
You've got a couple of options - here a two. 1 - You can target a page specifically, either by targeting it's slug or id. So say the page's slug is about, you can create a template called page-about.php.
2 - You can create a template file called about.php, and when you create your page, select the about page as a template. Just be sure to have the following at the top of the template.
/* Template Name: Name of Template */
Jaco Burger
20,807 PointsWhy would you want to do that if the pages are static? Vanilla html is fine for that. Are you talking about a CMS/Wordpress, or just plain PHP for the heck of it?
Sam Easterling
10,216 PointsWordpress. Some of the pages have dynamic content.
Sam Easterling
10,216 PointsYeah, those are the two options I had in my original post. Just wondering if I was on the right track or if there was a better way.
Jaco Burger
20,807 PointsHaha, sorry my bad. Not that I know of, it depends on what you're trying to achieve. If it is page specific, then option 1 I'd say, otherwise if you're going to re use functionality, option 2.