WordPress Widget: Most Popular Posts

I’m working on a revamp to the blog, and in my search for excellence I was unable to find a widget to display a link to the most popular posts according to the number of comments — something I want to add to “wesg 2.0”.

After finding an excellent tutorial on creating WP widget admin panels, I decided to make my own to have complete control.

The result of my labour is a very simple widget that displays a link to the pages with the most number of comments. You can customize the title of the widget, the number of posts to display and comment count.

You can also limit or skip single categories.

Download the Most Popular Posts widget now


  • Ricky — MySQL query to exclude posts with multiple categories
  • Ashish J. — Hindi translation and beta test
  • Branco — Slovak translation


  • Upload the file most-popular.php to your WordPress plugins folder.
  • Activate the plugin from the admin panel.
  • Go to the Widget admin page and customize the widget.

If you’d like to help improve development of this plugin and others that I have written, you can donate with PayPal.


Current usage is limited to widget only. Keep watching this to see if the template function returns.


  • Title: Most Popular
  • Show links to 5 posts
  • Display comment count
  • Posts with zero comments are included
  • All categories are included
  • No categories are excluded


v1.0 — August 14, 2008v1.1 — August 21, 2008
* Added support for using the list as a function in a post

v1.2 — January 6, 2009
* Updated for WordPress 2.7
* Add localization capability

v1.3 — July 18, 2009
* Added categories to exclude
* Added categories to include
* Switch off nonzero comment posts

v1.4 — August 6, 2009
* Added exclude category checkbox
* Added include category checkbox
* Stopped drafts from including

v1.4.1 — August 10, 2009
* Exclude posts with multiple categories

v1.4.2 — October 24, 2009
* Added support for custom CSS classes to match website theme

v1.4.3 — November 21, 2009
* Added ability to limit comments to posts within a certain timeframe

v1.5 — July 11, 2010
* Updated for WP3.0 compatibility and conventions
* Added reverse order option

v1.6 — July 18, 2010
* Repaired category and date behaviour

v1.6.1 — September 23, 2012
* Applied bugfixes for WordPress API updates

v1.6.2 — February 13, 2013
* Added Slovak translation

Something you want changed about it? Please leave a comment.

Tagged with: , , ,
141 comments on “WordPress Widget: Most Popular Posts
  1. GTL Media says:

    Mine no longer works with 2.8.3 period plus, as with Larry above, there is no “Uncategorized” option for me either, FWIW…

  2. Jason Beaird says:

    This is a great plugin, but I’m having the same problem as Andy Killen above. I need to add a class to the list, but in the custom HTML field, the plugin adds escape characters on each save and then doesn’t strip them out on the display end. So as far as I can see, there’s no way to add single or double quotes, and therefore no way to add CSS classes.

  3. Thomas says:

    Great Job…this is exactly what I have been looking for!

  4. Onore says:

    Simple and Great PlugIn – Thanks =)

  5. Scott says:

    Having the same issue as Naufrago above, except mine is line 79. This is on 2.8.4. Have used it before and its an awesome plugin, but now I don’t know what’s up. Anything I can do?

  6. alienman says:

    thank you for this handy and easy plugin! got it working in a mere 7 seconds!

  7. Bayrak says:

    Thank you plugin

  8. Sean James says:

    Great plugin, just installed it on my blog but i am having a problem:


    As you can see the Most Popular Posts widget is not styled like the rest.

  9. Tiffany says:

    Is there a way to alter the look of the title? When I install the widget, the title turns out looking very large and bold. Far more so than my other headers in my sidebar. I’d also like to change the color of the title text.

    Is this possible?


  10. T.M. says:

    Same problem with my site…

    Warning: Invalid argument supplied for foreach() in …/plugins/most-popular-posts/most-popular.php on line 79

    Any ideas? I’m not sure what this means or how to fix it.

    Thanks in advance for your help. I’ve been using this plugin for a long time now and hope to continue doing so.

  11. Steven says:

    Hello! Great little plugin…

    One question… I am using WPML to run a multilingual site. Is there any way that this can filter only posts in certain languages? So, if someone is on the spanish site, it only shows the spanish posts and not all the languages as it does now?


  12. wesg says:

    @T.M.: Thanks for the message, I will look into it.

    @Steven: I’ll also investigate the multilingual site option. Thanks for the suggestion.

  13. ahmed says:

    i need change stayle ?

  14. chat says:

    Great plugin! i had apply on my site~ thanks you

  15. Gray says:

    Hi, I’m using this great plugin with the Pixel theme…I’m having a tiny problem where the widget is appearing further to the left than it should be, sticking out from the sidebar and doesn’t seem to be inside a box like other widgets I have. Any idea how to fix this?

  16. bayrak says:

    thank you for sharing Congratulations on a very beautiful designed site

  17. Kenny Gor says:

    Anybody having problem with the thumbnail? it doesnt want to align to the left.

    please help. great plugin

  18. BGLH says:

    Hey Wes,

    This plugin is awesome, and I’ve used it on my site, but I am trying to figure out how to edit the line height so it doesn’t look so spacey in the sidebar.

    How can I edit the plug in to decrease the line height?


  19. Simon says:


    nice Plugin.

    But can you do it even more customizeable?
    For Example:

    The Option “Put in a a Parent UL Tag” is nice, but i would like to have it in a parent div instead the ul. maybe you could also rename the standard class to widget_…. to go conform with other widgets and css rules.

    thank you so far.

  20. Simon says:

    Another Great move would be to place it in the wordpress repository so that updates will be displayed in the wordpress dashboard.

    btw. Im using wordpress mu 2.8.4 and your plugin works like a charme

  21. wesg says:

    @Simon: Thank you for the valuable comments. I will take them into account when I update next. The widget is already in the WordPress repository, but blog panels can sometimes take a few days to show the update.

  22. Kenny Gor says:

    Hey Wes – sorry to bother you once again… any idea why my thumbnails are not aligned with the headers? I’ve tried it in 2 different themes, same thing. I’m not too good in CSS but I can give a donation for anyone who’s willing to help. thanks a million

  23. Kenny Gor says:

    Here is my content format:
    {image}{title}{summary} {stats}

  24. e-okul says:

    What would be most useful is if the plugin only sorted by approved comments rather than by total number ever. The amount of old spam comments showing up throws my list off.

  25. Anders Holm says:

    Nice plugin… Do it support all WP versions or is there a “version minimum” to be working ?

  26. wesg says:

    @Anders Holm: I test each version of the plugin with the most recent version of WordPress, but I imagine it will work as far back as 2.7. Any early than that and you may run into different behaviour.

  27. doug says:

    This would be most useful if I could restrict the timeframe of popular posts to like the last week or month.

  28. Reino says:

    Is there any way to show “most viewed posts of last month”, so not to show most viewed posts of all time but show posts of last 3 months (or 1). Would be great!

  29. wesg says:

    Thanks for the comments and suggestions. I will look into these features for the next update when I have time.

  30. bayrakçı says:

    thamnk you very nice

  31. Ninja says:

    Just downloaded the newest update and now it displays “popular posts” incorrectly. It appears to be taking my least popular content (posts with 0 comments) and displaying them now. It worked fine up until the update. What gives?

  32. wesg says:

    @Ninja: Thanks for catching that! It was a tiny code error during the update, but it’s been fixed now. A new version should be available shortly.

  33. Ninja says:

    Thanks Wesg appreciate the timely fix. I was looking at other popular post widgets, but they suck compare to yours. Glad I can stick with it 🙂

  34. Thanks for this i will use this for my article-nerd.com website, it is an article submission website, this plugin should be very handy, thanks for your hard work !

  35. PG says:

    I am using the function in my side bar but cannot find any of the settings to change.
    I am not using widgets.

    I am unsure about the usage and how to stop the comment counts appearing after the post name.

    help is greatly appreciated


  36. wes says:

    cool plugin! just curious, what data does this pull from to know which posts are the most popular?

  37. dude nice plugin – just the text is tiny – can you explin how to chneg the sixze of teh text pls thanx

  38. wesg says:

    @Benjamin Rama: I’ve set up the plugin so that text can be modified from the CSS file of your template. If it doesn’t match the surrounding text, experiment with the “nesting list item” option.

  39. Mark says:

    I would like to use the plugin on a page (only, and not in the sidebar–I use an EXEC-PHP plugin) and understand how to do that with . However, two things:

    1. In order to configure it I have to insert the widget into a sidebar, configure, and then remove it from the sidebar. It would be helpful to be place to have the configuration options in the Admin.

    2. Also, or instead of, tell us how to insert the configuration parameters right into , if that is possible. Then, I can tell it to display as I want when I place it on a page. And the great thing about this would be that I could then have multiple instances of it (i.e., Most commented all time, and another for most commented last month). This would be VERY helpful.

    3. Add the ability to sort the list with the most recently commented article at the top, descending order.

    The reason I would like these things is that I am setting up a page called Forum. Admittedly, it would be no where near a forum, but I could quickly show the readers “where the action is” in several lists, which would dramatically increase page view. I thinkj these changes would open up new opportunities for your plugin.

    Thanks for you consideration, and love what you’ve done so far.

  40. wesg says:

    @Mark: thanks for those comments. This week I will be reviewing my plugins and making suggested changes. I think one of those changes will be an admin panel to override the widget properties.

  41. Glenn says:

    I just updated to the latest version of this plugin. Now it only says “No posts to display.” 🙁

  42. wesg says:

    @Glenn: This is because no posts fulfill the criteria in the settings. Have you tried different conditions?

  43. Ben says:

    Great plugin, however, I am having problems styling it. I got the list items to work right but the title is large and bold. Cannot seem to get it to match the other titiles on the sidebar. Tried the nest option but didnt work.

  44. Tomi says:

    It is worked on WordPress 2.9?

  45. Hazel says:

    Hi, Can it be most viewed page or post? Thnaks

  46. shoaib says:

    nice plugin and most of all its really clean.thnx

  47. bayrak says:

    thank you for sharing