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 trialBrian Kershaw
7,490 PointsHow would I do this if I wanted each page to follow a different template?
I have followed the tutorial and have got it working but i need the "pages" to have different template/layout. Currently in this tutorial all the pages follow the same template/layout.
5 Answers
Kevin Korte
28,149 PointsSay you had a /portfolio page, you would have a template page-portfolio.php. And if you had a /contact page, you would have a page-contact.php. I think that will work for you
https://developer.wordpress.org/themes/basics/template-hierarchy/
Anastasiya Goers
2,249 PointsI am trying to do the same thing as Brian. I can output different page templates by running the loop multiple times on the single layout page but it is not the ideal way obviously. Any help would be greatly appreciated
Kevin Korte
28,149 PointsWould this help solve the problem? https://codex.wordpress.org/Function_Reference/get_template_part
Brian Kershaw
7,490 PointsHi Kevin, I tried using the get_template_part to pull in the different page templates. My issues with this was the get_content on each template would only pull in the content of the main page that the the get_template_part was being placed. It would not pull the content from their own page.
I'm guessing this had something to do with the loop?
Sergio muñoz
2,128 PointsI can't customize each section of the page, for example #about-me. I want to style with CSS to give it an width o color background but for some reason the CSS is not detected. Please help!
Jerome Diehl
2,678 PointsI also have the same problem as Brian. I'm a bit discouraged that the Treehouse staff has failed to answer his question after 10 months. Anyone figure this problem out yet?
Brian Kershaw
7,490 PointsBrian Kershaw
7,490 PointsHi Kevin, Thanks for your reply. I am aware of this and already have the pages created and set with templates as page-contact.php, page-about.php etc..
What I am trying to do is then pull these pages (along with their templates) into one long scrolling homepage.
So each page will be a section of the only page of the site but they all have different templates.
Currently I can only get it to pull the content of the pages but not the template layouts themselves. This video show me how to pull the pages but they are all set with the same template in content-page.php.