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

General Discussion How to Build a WordPress Theme WordPress Theme Functions The WordPress Loop

pages in wp-admin

While following these tutorials, I've managed to make everything work as shown (a miracle indeed). However, I have come across a problem. I created all the .php files as outlined in a previous video, but when I go into wp-admin, all I see is the sample page. The front-page.php file is active as I can see all the content, I just don't see the list of pages.

I know how to make a page in the dashboard. However, the page doesn't correspond to the files I created. Am I supposed to have created the pages before this?

I am using the latest wp build: version 3.8.1

Any help on this would be greatly appreciated.

Steve

10 Answers

Create the pages in the admin and under 'Page Attributes" select the .php template for that page. Even though you created the .php file, you need to add the page to the db by adding new pages with the templates.

Thanks Christopher for the answer.

I do have a follow up question (please excuse my ignorance): I do not see my .php templates listed. Is there a way to surf to them?

I looked on the codex, and it shows a template option under the normal page selection. Unfortunately on my screen, that option is not available. I'll keep looking.

Thanks for your help.

Are your .php template files in the correct folder?

They are in the main theme folder I created. I don't have them in any subfolders as of yet.

Also, I'm running this locally with MAMP, so I shouldn't have any security issues or other server-side issues.

OK the menu now appears under quick edit. Now, none of the files are listed there.

/**
* Template Name:PageofPosts
*
* 
*
* @package ThemeName
* @since ThemeNameVersion 1.0
*/

Do you have something like this at the top of your .php template files so Wordpress knows they are template files and what the template name is?

    I didn't, but looking at the files in the project folder I downloaded from Treehouse, Zac doesn't either. Also, his blog page comes up with several different generic blog postings. Mine comes up with the same thing as my home page. There is still something I'm missing. But I'm glad I have the first hurdle completed.

OK I found the answer. I have to put <?php /* Template Name: My Custom Page */

at the top of each of my pages. Then, they show up. That would be a nice thing to have in the notes of the tutorial, or as a comment. Maybe that is common knowledge…wasn't for me.

I thought that might be the issue. Glad you got it figured out.

Go to Settings->Reading and check what the 'Front page displays' is set to. It will be 'Your latest posts' or you can select 'A static page'. Do you have a separate template for your home page and blog page? If so, what are the template names?

The front page is set to static. I did realize that it was posting a generic blog. The thing that threw me is that it was only displaying one post instead of the three that the video shows.