Creating a static home page and dynamic blog page in WordPress 2.3

I’m having issues right now with WordPress. The problem isn’t lack of documentation, it’s the lack of current and consistent information that is driving me crazy.

WordPress 2.2x introduced functionality to choose a page as the static home page. This feature fixed the need for several plugins and hacks.

  1. Create a page in your WordPress Admin with your preferred home page info
  2. Go to the options –> Reading submenu and select “Front page displays:”. For the front page, choose the page you just created
  3. Check your tabs, do you have duplicate home page tabs? I had a custom topnav and had to add logic to not display the new page in the top nav
  4. You may want to re-arrange the tabs to put your new home page in first place. Here’s a great plugin: mypageorder.

Static home page is complete

So, that was fairly easy. You now have a static home page, but those great blog posts you’ve been writing are missing. The static home page does not activate the Loop, the code that handles blog posts, archives, etc. So now you need to create a new section for your blog posts.

This is where it gets confusing. There are as many suggestions as conflicts. For every version, there is a reference to conflicts with this page, this version, this etc… The following are some of the twiki suggestions

Setting up your blog in a different subroot

This twiki section describes how to set up your blog post outside the root. However, notice the comments toward the end about conflicts. I’ve tried this method and couldn’t get it to work in WordPress 2.3.1.

Suppose you have WordPress running at http://example.com/. Suppose further that you want your blog to be located at http://example.com/blog/ and that you want other pages to be available at http://example.com/page1/.

The first thing you will want to do is to create a home page. You can do this by creating home.php in your theme directory. Next, create a blog template. The easiest way to do this is to create a file named blog.php with the following contents in your theme directory:



Log into WordPress and create a page named “Blog” with template “blog”. You’re done. The one last thing you will want to do is to update your permalinks structure to begin with “/blog/”, ie, “/blog/%year%/%monthnum%/%postname%/”. Now you have a WordPress-managed CMS with a unique front page and logically-structured blog content.

If you’re using the <!– more –> quicktag to place things below the fold in your posts, you’ll want to include the global variable $more and set it to zero (as shown in the code above). Otherwise, the entire post will print out on your blog’s main page.

As noted above, the home.php file is not needed in versions 2.1+. If both the blog.php and home.php files are deployed in 2.1+ they will conflict and cause the blog.php templated page to appear blank. [emphasis – TED]

Making your blog appear in a non-root folder

The outdated resource page

WordPress has a page in its twiki specifically for static pages: Creating a Static Home Page. However, it’s filled with warnings about conflicts and doesn’t solve the lack of blog pages.

UPDATE: With the release of WordPress Version 2.1, the option to set your own front page can be accomplished via your Administration > Options > Reading panel. However unlike the old explanation that follows, you must NOT name your home page template file “home.php”. If you do, this will cause a conflict with the WordPress 2.1 system. The approach that follows on this page is no longer necessary with WordPress 2.1 or newer
Creating a Static Home Page

Reading Options Subpanel

The Reading Options Subpanel twiki tells you how to select a page to be your new blog index. It just doesn’t tell you how to create that page.

…A static page (select below) – select this option to cause a “static” Page to be displayed as your blog’s front page. At the same time, choose the Page that will display your actual Posts. The Front page and Posts page cannot be the same value.

  • Front page – in the pull down box, select the actual Page that you want displayed as your front page. If you do not select a choice here, then effectively your blog will show your posts on both the blog’s front page and on the Posts page you specify. If you would like to create a static home page template file, do not name it home.php, otherwise you will encounter problems when you try to view the “blog”/”posts” section of your site. To get around this, just name it anything else, example: myhome.php
  • Posts page – in the pull down box, select the name of the Page that will now contain your Posts. If you do not select an option here, then your Posts will only be accessible via other navigation features such as category, calendar, or archive links.

Reading Options Subpanel twiki

Turbocharged option

Turbocharged CMS has a variation on the static home page, but references the builtin WP 2.1 option. It works by creating a home.php file and then setting a filter to display the home page or the blog page

How it works

It’s rather simple. When home.php exists, it’s automatically loaded in lieu of index.php when someone visits the front page of your blog.

This version of home.php does one clever trick: it redirects visitors on your main URL to your static page. But the story doesn’t end here — otherwise you’d be left without a way for readers to read your blog front page.

To perform the redirection accurately, home.php first examines the WordPress engine to look for query arguments:

* If the front page is visited with no arguments, then the reader is redirected to the designated static home page
* Otherwise, the standard arguments are processed like usual, and index.php is called on to perform the display of the requested posts
Creating a static front page on your WordPress blog

This sounds good until you remember the WordPress twiki page warning not to use home.php and blog.php at the same time.

So what is the solution?

What is the best method to create the blog index page once you’ve added a static home page? I’ve created the new blog template for the blog section as described in the previously mentioned twiki. I created a new page: blogs and set that page to use this new template. I have gone into the reading options panel and selected this page to be the posts page index. The result? A 404 page. Sigh.

Have you found a fix for this?

Author: Ted

Accessibility is more than making sure images have alternate text. I work with engineers, product managers, and designers to understand how accessibility impacts the users, set realistic deadlines, and create the solutions to provide a delightful experience to all users, regardless of their physical, sensory, or cognitive ability.

4 thoughts on “Creating a static home page and dynamic blog page in WordPress 2.3”

  1. Hi there,

    Excellent information given. I wonder how come no one has commented on it yet. Either people are too lazy, or you cant be found through Search Engines(although I did find you thro an SE)

    All I wanted to say is it superb info, and I found it very informative and helpful! Thanks, also great links!

  2. Having just upgraded to WordPress 2.3.2, I wanted to use the new ‘Static front page’ option but found the “…Posts page – in the pull down box, select the name of the Page that will now contain your Posts…” instruction a bit on the vague side.

    However, what I did was to go into the Admin section and go to Write | Write Page. I wrote a page to use as my static front page and gave it the title “Main page” then I wrote another page but just gave it a title “Latest Articles” and put no content on the page, to see what would happen.

    In Options | Reading, I set the Front Page as “Main Page” and the Posts Page as the empty “Latest Articles” Page.

    I’m not sure how to set different templates for the two Pages yet, but for the time being I don’t need to do that and I’ve got the result I was after. The static Welcome page now displays by default and when I click on the Latest Articles link in my sidebar it displays the posts.

    Hope this helps someone out there.

  3. I discovered the problem I was having may be unrelated to the static page. I couldn’t create ANY new pages at the top level. I created a page that was a child of another page and could then easily point to that as the posts page.

    I think this may be a side-effect of an otherwise helpful plugin that lets you easily re-organize your page hierarchies. It’s got a drag and drop interface that lets you easily set the topnav order. I should disable the plugin and check again.

Leave a Reply

Your email address will not be published. Required fields are marked *