Separating posts, pages and homepage in WordPress – clean and simple way

September 12th, 2009
|

I played a bit with separating posts, pages and the home page in WordPress today. I tried to find a solution with Google, but there are some tutorials only about the posts and pages separation. I needed something more! And I found the solution what I would like to share with you.

Home page, pages, posts all in one CMS

  • I have a let’s say “independent” home page (the welcome page)
  • I have static pages with static navigation
  • and I would like to write posts so I need:
    • posts listing page
    • single post displaying page

To see the result just look at Eldanor.hu itself. The site have a custom welcome page. There are pages with different sidebars and there are blog posts.

Sounds a bit complicated but it is very easy to implement the whole thing in WordPress. The more good news is that we learned a simple but magical thing about WordPress.

Let’s get started!

Make a homepage template

You can create a HTML or PHP file for your home page depends on your needs. To make it simple call your file homepage.php. Place this file in your currently used template directory (for eg. ./wp-content/themes/templatename).

Add the followings in the beginning of your homepage.php

/*
Template Name: HomePage
*/

You can select this template for your pages!

Do not forget that this “template” contains any PHP code, any HTML or JavaScript – so you are able to create a homepage as you like.

Create your Home page

After you created your HomePage template you can create your Home page. Go to your WordPress admin and there on the left hand side select Pages, and then selec “Add New”. Write Home in the title field and leave everything blank. You have to select a template for your new page. Select the “HomePage” template from the Template dropdown in the Attributes box. (Do you remember? We have created our HomePage template in the first step.) Now you can hit the Publish button!

Create your post listing page

Go to Pages and select “Add New”.  Write Blog in the page title. Leave every other field blank and hit the Publish button.

Do some magic

Now we have two new pages. The first is called Home and the second is called Blog. We joined the Home page and our homepage.php template together.

We have to do some easy steps in the WordPress Admin. Go to Settings and select “Reading”.

How to set your front page in WordPress

How to set your front page in WordPress

You have to select the “A static page” option. Then select your Front page from the dropdown menu – our front page name is Home! Select the Posts page. Our front page name is Blog. Hit the Save changes button and leave WordPress to do the magic!

Now you can see your homepage.php as your homepage (welcome page) and if you like to see your blog posts you have to navigate to blog (for. eg. http://www.yourdomain.com/blog/) and even more you can create pages. All of these are separated and easily managed now from the WP admin!

That’s all!

Leave a comment: