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; ?>

3 thoughts on “Display 10 recent post titles on homepage

  1. 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

  2. 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.

Comments are closed.

Twitter
LinkedIn
YouTube
Instagram