Web Development Blog

by Ei Sabai Nyo

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.
Your name:   Your email:  

3 Responses to “Display 10 recent post titles on homepage”

  1. Vanessa says:

    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. eisabai says:

    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.

  3. steven jeggels says:

    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.

Profile PicHello! 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 about me or have a look at some of the tips & resources I've written.
Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
We do NOT spam.
Your name:  
Your email:  

Tips & Resources

Tips & Resources
WordPress Web Hosting
Recommended web hosting providers for WordPress 3.0
iPhone Native App Development
Important steps into iPhone app development for beginners
iPhone Web App Development
Tips for iPhone web app development
Coupons for Web Developers
Get discounts on web hosting, domain names, templates, etc
10 Useful jQuery Snippets
Easy-to-use jQuery snippets for any website
HTML Email Newsletter
Step-by-step tutorial on how to code an HTML email newsletter
  • bluehost Hosting $6.95/month
  • Joomla Templates

Recommended Book

Categories