WordPress – List your most popular Posts

This function below creates a list of links of the top commented posts on your WordPress blog. It builds this list based on the posts that have the most comments. Place it in your footer or sidebar item!

Call the function in your sidebar of footer like this:


15 thoughts on “WordPress – List your most popular Posts”

  1. It seems as though that if you had a lot of posts that your script would have to query the whole DB to find just the top 5 most actively discussed.

    1. Wouldn’t it be better to change the query to limit to the last 60 days so that not only would you only have the more relevant articles but also so you don’t have to query the whole DB? Or would you still have to query the db anyway?

    2. Ideally, it would be nice to set this up to rebuild as a cron job once per day and just include what is built by the daily job… no? Do wordpress offer anything like that? For instance, why build the category list every single time the page is hit when mine hasn’t changed in the last 6 months.

  2. hi Richard

    Great code, thanks for that. One question if that’s ok. How would you add more details to the list? Id love to be able to add more of the content, perhaps even categories. Is this possible? Thanks again for the code!

  3. I’ve been around the web and around the web some more and it seems everyone is doing a great job at building this function.

    However something that is missing is a tutorial on how to get it to display like the normal post loop that everyone has on their homepage or category pages.

    This only shows a list of the titles with links.

    Can you do a tutorial on how to display like that?

    I’m betting it will be immensely popular if you do.

    Speak soon hopefully.


  4. hi,

    Just found this and its exactly what I’m after.

    Is there any way of assigning a different class to each so that i can use a different font size for each?

  5. This post, I really like, hope you write this more…keep your good write…and wish we can make a good relationship, would you like to exchange link with me??? I’m very grateful if you will…thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *