Psuedo-static Homepages in Wordpress
Note: This post is over 2 years old. You may want to check later in this blog to see if there is new information.
The following links are auto-generated but may help you locate newer content:
I use Wordpress for a lot of my smaller client sites. It actually makes a decent CMS with a little hacking. It defaults to a blog style home page, but it’s simple to create a static page, old school style. However, I’ve had several clients lately that love the idea of a blog style front page that allows them to keep content fresh, but can’t get away from the idea of having the “About” information be the first page. So I came up with several workarounds, one of which I’ll detail in this post. It uses a “Banner” category to create a sticky post at the top of the page, and then a secondary query that excludes the Banner category to fill in either below the banner or next to it, depending on your design.
Create a category
Basically, all you need to do is create a category called Banner (or whatever you like). Take note of the ID of the category in the Category Management page of the Wordpress admin panel. Now you’ll create a post (or more than one) and assign it to this category.
Set up the Home Page
Next you’ll create a file in your theme directory called “home.php”. If Wordpress detects a file with this name, it becomes the default home page. This allows us to customize the start page outside of whatever theme we’re using. So set up your XHTML to contain the banner post and add a query that only grabs the Banner category.
<?php query_posts('cat=4&showposts=2');?>
You can show multiple posts with the “showposts” parameter. I allow for 2 posts in the Banner category, if they don’t use the second post, it won’t display.
Show the post
Next you set up your loop to display the actual post(s). I set mine up to include a headline, not linked, and the post, with no date or meta information, and definitely no comment options.
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2 class="articleHeadline"><?php the_title(); ?></h2>
<p class="article">
<?php the_content('Read the rest of this entry &raquo;'); ?>
</p>
</div>
<?php endwhile; ?>
<?php endif; ?>
Add the news
You can then follow that with a query that either includes just a news category, or excludes just the banner category. You can copy the rest of the code out of the standard loop and edit the parameters to fit your needs. For more information on the query_posts command, see the Wordpress Codex page.
Another Solution
One of my other methods is to actually create a page template for home.php that includes home as a static page and then adds a sidebar with an “asides” category. You can get the gist of how to do this by studying the K2 code. 
clients» CMS» hacked» template» webdesign» wordpress»
7 Comments
Jump to comment form | comments rss [?] | trackback uri [?]