WordPress

WordPress: Build a Home Page in 3 Easy Steps

I was working on a site for a friend today who had WordPress but he wanted a simple home page rather than a home page utilizing the latest blog entries.

This is really useful if you’d like your blog to be a part of your site rather than the entire site. You can basically utilize WordPress as a CMS. Below I concentrated on ‘3 Easy Steps’ so if you’re an advanced developer who utilizes WordPress, don’t give me a lot of guff. 🙂

Some people really go through some difficult steps to do this, but there really is a simple way… here’s how using the default theme:

  1. Copy your Page Template (page.php) to a new file called home.php and put it in your theme directory. This is a supported feature of WordPress… it will look for home.php first if it exists.
  2. Make a new Category and call it Home Page. Remember the Category ID number… you’ll need it in the following code.
  3. Overwrite the Loop in home.php with the code below. This basically filters out any other content except the content posted to your new Category called Home Page. Be sure to substitute the Category ID below in the quotes in the cat=1 statement. I also asked to sort the posts ascending since that’s more appropriate.

That’s it! You’re done! If you only want a single article on that page, just write one post and update it whenever you wish to update your home page! Voila!

<?php query_posts('cat=1&order=ASC'); // include home page only and sort ascending ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
<?php link_pages('<p>>strong>Pages:</strong> ', '</p>', 'number'); ?>
</div>
</div>
<?php endwhile; endif; ?>

If you’d like a plugin for assisting in making a home page, you can utilize this one.

4 Comments

  1. 1
  2. 2
  3. 3
  4. 4

Leave a Reply