The issue of using a portal-style home page in WordPress has come up a couple of times recently. I’ve tried to help some people with the code and settings. I’ve learnt a fair bit in the process that I thought was worth sharing.
WordPress can use a file called home.php as a homepage, which supercedes index.php. Allowing you to show whatever you like on your homepage. Now, WordPress v2.5 gives you the option of using a “page” as the home page of your blog/website. I like this method much better, because it allows a home page and the regular blog/posts page.
To do this you need to
- Create your home page
- Create a posts page
- Change the Reading settings
On a slight tangent. I highly recommend that you enable custom permalinks. Doing so will allow for sensible page addresses. For example the ‘about’ page will be at www.example.com/about/ instead of www.example.com/?p=2 (or something like that). Later, when you create the posts page, it can be at www.example.com/blog/ or /posts/ or /articles/.
There’s a pretty good explanation for changing the permalink structure at Blog Tutorials.
Create a home page
Presumably you are familiar with writing posts and pages — your site would be pretty skint without them!
The first step of creating a home page is no different from any other page. Go to Write > Page.
Give the page a suitable title, such as Homepage or Home and save the page. By default the title of the page will become the post-slug or permalink name; i.e. a page called Homepage will be found at www.example.com/homepage/. In WordPress v2.5 you can edit the permalink under the Title.
Home page content
Adding the home page content can be as easy as writing a post — if you want static (unchanging) content. This kind of page will be displayed with the standard page template, which usually looks the same as a post page (header, content, sidebar, footer).
The other option is to create a Page Template, which is a little more involved. I’ll cover a bit about this in a later post.
Once you have the content you want on the page, be sure to Publish it. You might be able to see a saved (but not published) page when you’re signed in, but others won’t.
Create a posts page
All you need to do for a posts page is Write > Page, give it a title such as Posts or Blog (whatever you want the address to be). Publish the page.
When you apply this page as the posts page it will use index.php to show the posts.
Change the settings
To activate these pages go to Settings > Reading, choose “Front page displays a static page”. Then select the pages from the two dropdown boxes.
Voila! Separate home and posts pages.
Do you have any questions? Do you want to put something on your home page, but don’t know how? Leave a comment and I’ll try to cover it in the next post.
Follow up post: Create a custom homepage in WordPress: the content.