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.
- Create a page in your WordPress Admin with your preferred home page info
- Go to the options –> Reading submenu and select “Front page displays:”. For the front page, choose the page you just created
- 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
- 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:
Template Name: Blog
// Which page of the blog are we on?
$paged = get_query_var('paged');
// make posts print only the first part with a link to rest of the post.
$more = 0;
//load index to show blog
load_template(TEMPLATEPATH . '/index.php');
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]
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.
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?