09 Feb, 2009
Display 10 recent post titles on homepage
Web Development » WordPress » Display 10 recent post titles on homepage
Someone emailed and told me that they liked the Recent Posts feature on my blog homepage and would like to know how I did it. Well, it is actually very simple, there is no plugin or widget – all you need to do is add the following snippet to index.php of your WordPress Theme.
<?php if (is_home() || is_front_page()) : ?>
<?php query_posts('showposts=10'); ?>
<div class="recent">
<h2>Recent Posts</h2>
<dl>
<?php while (have_posts()) : the_post(); ?>
<dt><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dt>
<dd>Posted under <?php the_category(', ') ?> on <?php the_time('F j, Y') ?></dd>
<?php endwhile;?>
</dl>
</div>
<?php endif; ?>
Other similiar posts that you might be interested in:
- Display 5 latest posts in each category in WordPress
- Customising category.php in WordPress
- 5 steps to creating a custom Archive page in WordPress
- Highlight the current page link in WordPress
- Golden Green WordPress Theme – Download
- How to add a breadcrumb to your blog and have it appear on Google’s Search Result Snippet
- How to customise WordPress Admin Login page






