09 Feb, 2009
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; ?>
Love what you've just read? Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
Other similar 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
- Golden Green WordPress Theme – Download
- Highlight the current page link in WordPress
- Top 10 jQuery Mobile Code Snippets that you need to know
- How to add a breadcrumb to your blog and have it appear on Google’s Search Result Snippet
Hello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more 


Hello,
I am interested in purchasing content advertising on eisabainyo.net, Is it possible to get some pricing and information with regard to doing so?
I work for Web Hosting Search in business development and I’m in the process of looking for strong sites to build relationships with, in advertising or other forms, if you have other suggestions.
Let me know what you think.
Regards,
Vanessa
Hello Vanessa,
Thank you for your interest.
You can buy ad spots on this website via BSA: http://buysellads.com/buy/detail/22523/zone/1245775
Or if you have any other advertising enquiries, please contact me via email at eisabainyo at yahoo.com.
your tutorial about recent posts feature on my blog homepage is very educating. however, how can i display the latest blog posts in a div on a page of my website (e.g http://www.example.com/index.php) and not on a page of my blog. my blog would be located at http://www.example.com/blog. appreciate your help.