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

Gabriel Ward
Gabriel Ward
20,222 Points

WordPress Static Front Page

I'm customising a theme that doesn't have a home.php file. So I think that the index.php file is controlling my blog listing page, which displays all my posts. I'm trying to set it up so that I have a static front page with a link to the blog page, where all my posts are displayed, on this static front page. I'm not quite sure how to do this. Any help is greatly appreciated.

3 Answers

Hi Gabriel, it sounds like what you are wanting to do is setup a custom, static home page. This should definitely help you out with that: http://codex.wordpress.org/Creating_a_Static_Front_Page

If after reading the codex documentation you still aren't clear on how to handle it, definitely post back. Just as a heads up, I also edited your post title to be more descriptive of what you are looking to accomplish so it is more helpful to other members.

Gabriel Ward
Gabriel Ward
20,222 Points

Thanks Mike,

So after reading that, I've done the first basic steps. I've created a Home Page and a Blog page in the admin. Then I've selected Home Page for the front page and Blog for the posts page. When I click on blog in the menu, it says the page doesn't exist and that I should visit the homepage.

The theme doesn't have a front.page.php or a home.php. Do I need to create custom templates?

The posts display no problem if I have the front page as displaying blog posts.

What I have typically done in the past is:

Create a home page template, something like page-home.php or template-home.php will work. At the top of the template file you will want to have your custom template declaration like so:

<?php 
/* 
Template name: Home 
*/ 
?>  

Go into pages and create a home page, you can simply call it Home and assign the Home page template to it. Within the custom home page template is where you will have your markup for how you want the home page displayed. Whether that is listing blog posts or showing other content is entirely up to you and the design you have in mind.

As for your issue with the blog page, what is the URL you are visiting to access it? Are you certain a category exists with that same URL?

Gabriel Ward
Gabriel Ward
20,222 Points

Ok cool thanks for the help! I just solved the issue. I removed the blog page from the menu and then added it again and it seemed to work. So now I have a static front page with a menu on it, and on that menu is a link to the blog posts page, which is what I was after :)

Great! Glad it all worked out.

It's a little confusing, but WordPress uses home.php for the blog page, even when it's not your home page. There's another page template named front-page.php that gets used for your non-blog static front page. So, if you have set a static front page and a blog page, the static front page will look for front-page.php and the blog page will look for home.php. This confused me for months!

Good luck!

Richard