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.









You should do the same for recent comments
I don’t think this can be done for comments.
There is a way actually, not as easy as this though. I’ll make a post soon about doing recent comments.
Told ya BANAGO, there is
I know its not as easy, but it would help people. I remember how to do it now.
@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.
Yea i know that
I didnt say it was lol
Anywhoo. Nuff said
good ways~!
I hope it can works in my blog
This is perfect! Exactly what I needed to show the most recent posts in a church website’s main page design. Thanks so much for the tip!
How about a version where you exclude certain categories from the recent posts? this function doesn’t allow the exclusion of categories. I am using it inside the loop before the call for the actual post title in a lefthand sidebar and found that the other version of a custom database query fed the last post title into the main post the_title(). If I use the version you supplied then it doesn’t feed the wrong title to the post but I can’t exclude a few custom categories that feed my news and portfolio.
Thanks a bunch, worked beautifully!
eh thanks.
what should I do to add a header to the lists?
thanks again.