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

Displaying Custom Posts and Fields in a Template issue

After adding my template to the work.php file and selecting it in WP, my page came up blank. I just added the php closer "?>" after the commented part in the work.php file. I didn't see you close the <?php on the video so I just want to make sure I'm doing it right. Thanks!

8 Answers

I figured it out. the get_header was closed with

<?php get_header(); ?>
Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Glad you got it! And kudos for popping it up in the forum incase anyone else has the same problem!

My work page keeps using the default home.php template instead of the work.php even though I've selected the template from the drop-down menu and have setup the template correctly.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hmm, tricky one Caroline McQueen

The template order of use for the work.php page should be work.php, page.php, index.php. It shouldn't ever default to the home template, although a lot of these templates are similar at this point.

If you rename work.php to _work.php does that change anything?

That worked! Thanks :)

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Oh good! Wasn't too sure what to suggest next :p

I'm curious what the bug fixing process was like and at what point you figured it out.

First, I deleted the browser history and restarted the local server. When that didn't do anything, I deleted the work page in wp and re-made it, reselecting the template. After that, I made a new work.php file and but named it "page-work.php". That didn't work either so I tried giving the php file a random name to rule out a conflict between the work page in wp and the work.php file.