You don’t need any custom queries or database calls just to get a list of recent posts. In fact, there’s a function built into WordPress that will do just that. It’s called, wp_get_archives(). You might recognize that as a way to display monthly archives, but with a few parameters, you can modify it to display a list of recently published WordPress posts. Here’s the code:

<?php wp_get_archives('title_li=&type=postbypost&limit=10'); ?>

What this will do is strip any WordPress added formatting and output a nice list of the 10 latest posts, each within it’s own <li> tag.

Subscribe to RSS

By: Leland on May. 26

Bookmark and Share

8 Comments »

Comment by Anto Subscribed to comments via email
2008-05-27 03:22:54

You should do the same for recent comments :P

 
Comment by BANAGO
2008-05-27 10:39:00

I don’t think this can be done for comments.

 
Comment by Leland
2008-05-27 13:12:22

There is a way actually, not as easy as this though. I’ll make a post soon about doing recent comments.

 
Comment by Anto Subscribed to comments via email
2008-05-27 13:25:36

Told ya BANAGO, there is :P

I know its not as easy, but it would help people. I remember how to do it now.

 
Comment by BANAGO
2008-05-28 07:39:40

@Anto: I am sure there is as I have implemented that at almost all the blogs I have designed, but what I meant was that it is not done on the way the archive is done. :)

 
Comment by Anto Subscribed to comments via email
2008-05-28 07:47:52

Yea i know that :) I didnt say it was lol :P

Anywhoo. Nuff said

 
Comment by KimCool
2008-05-30 07:50:31

good ways~!

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post

Recent Comments

  • Leland: Phew…just got back from a vacation. I just moderated a ton of pending comments. Anyway…...
  • IndieLab: @ mike, You can contact me through my site, and I can give you a quote.
  • Mantra Lighting: Great job on the theme. Love the colors and it’s very clean!
  • Mayur: wow awesome theme dude :D Thanks for your god work
  • mike: im looking to get this theme set up any one want to make some money i suck at coding lol email me

About The Author

Welcome to Theme Lab. My name is Leland, and I run the place. I write all the tutorials and code all the themes you see here on the site.

For more information about me, feel free to read the about page. If you want to drop me a message, feel free to contact me.

Interested in advertising on Theme Lab? We have advertising available at very reasonable rates. Head on over to the advertising page for further details.

Please read our Privacy Policy and Terms of Service in regards to theme usage.

© 2008 - Theme Lab - Powered by WordPress