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.

Posted in Wordpress Tagged with: , , ,
141 comments on “WordPress Widget: Most Popular Posts
  1. Gajogeje says:

    Hi, it´s a great plugin, but i have a question. In the new version, the options are in the widget, but if i want paste the code in my template, how can i manage de options?


  2. wesg says:

    @Gajogeje: Currently the widget settings change a single function, meaning settings affect both a widget and a function, should you use one. In a future version I will try to include multiple instances of the widget.

  3. Brook Lenox says:


    Really like this plug in! (but have an issue).

    I’ve got WP 2.9.1.

    In internet explorer the posts look fine, but in Firefox 3.5.7 the post titles have funny little bullets and the text is tiny.

    Is there something I can do about that?



  4. Brook Lenox says:

    Hi…also is there somewhere it explains how to use the formatting options (parent list item class, child UL class, list item class).

    I’m clueless here. Thanks!!!


  5. dilek says:

    Perfect plug-in and works without problem. Thank you very much.

  6. wesg says:

    @Brook Lenox: I’ll look to get another tutorial online shortly. Thanks for the comment!

  7. bayrakci says:

    Thanks for the post

  8. forma says:

    Hi, Can it be most viewed page or post?

  9. Karin says:

    good plugin, i like it.. thanks

  10. kenneth says:

    Thank you, perfect plug-in.

  11. thank you for sharing

  12. miette says:

    Ummm… a fellow above had mentioned a little problem with showing the Least Popular Posts. You fixed that, which is nice. But you know, I’d like to be able to show my readers my Least Popular content, to get it up to the top. Which I know I know is ridiculous, but I can’t believe there’s no widget or plugin for this. Is there an easy way to hack what you’ve got here? Please?!

    — Mtte.

  13. wesg says:

    @miette: Certainly, it is just a matter of changing the database query in the main file. I can send you a copy of the modified one if you’d like.

  14. mike duran says:

    I’m having the same problem Brook is having. Using WP 2.9.1 and in Firefox the post titles have little bullets and small text. I’ve removed it for now.

  15. Hikari says:

    Very nice plugin!

    But I noticed it doesn’t follow widget standards. Themes use to set some configs, like main list classes, widget title’s before and after, etc.

    Your plugin doesn’t follow these standards, so its widget is shown different than others. In my theme, title doesn’t have background and lists are broken, due to lack of classes.

    Instead of following standards, you set these stuff in widget config. But for exemple my theme’s wisget’s title is h6, while your widget has h2 hardcoded.

    I’m not complaining, I liked it very much and it has all the logic. I’ll probably fork it into a brand new plugin taking it’s logic so that I can use it :)

  16. biber hapı says:

    I’m having the same problem Brook is having. Using WP 2.9.1 and in Firefox the post titles have little bullets and small text. I’ve removed it for now.

  17. wesg says:

    @Hikari: Thank you very much for pointing this out. I haven’t had time to modify the behaviour yet, but I’m hoping to get to it soon.

  18. steve says:

    I was wondering if is possible to list most popular from a specific page category and nothing above and below of it.

    parent -> child -> sub child

    I want to list most popular “child” pages and nothing above or below.

    is this possible?


  19. wesg says:

    @steve: Not currently, but I’ll add it to the list of upgrades for the next version.

  20. I’d really like to be able to pass all the options as parameters when calling this as a function. Specifically I need it to only show me the Most Popular posts in the past four days.


  21. Jim says:

    Hi wesg. I love your script, but it seems to not work with wordpress 3,0. Please say that you’re working on a update.

  22. wesg says:

    @Jim: I am indeed. The last day I updated it to work with WP 3.0 and will release it tomorrow or Tuesday.

  23. mirc indir says:

    thank you ju amst gorry!

  24. Andrew says:


    I want to use this plugin but it isn’t working. When is select to show only posts from the last week, it count’s all posts (also older).

    What’s is going wrong?

  25. wesg says:

    @Andrew: I’ll look into it.

  26. Andrius says:


    I like your plugin for its simplicity. I’m using it in multi-language website, along with qtranslate.

    I found that by default it displays all post titles (in all languages), if you want to show only one language change this “$links->post_title” into this “__($links->post_title)”.

  27. Cintia says:

    Hi there,

    Is there a way to change titles from H2 to H1??


  28. wesg says:

    @Cintia: the widget now takes into account the WordPress global settings for widget titles. If you read some of the WordPress documentation, you’ll find you can register a sidebar in your theme with whatever title tags you wish.

  29. mirc says:

    I want to use this plugin but it isn’t working. When is select to show only posts from the last week, it count’s all posts (also older).

  30. Hello,
    I upgraded from 1.5 to 1.6 and I got an error.

    Please let me know what I need to do to clear this up. It occured after I installed the plugin
    The website is – http://www.ja-nae.net/blog

  31. manu3l9816 says:

    is there any way to make this widget displaye the post thumbnail generated by simple post thumbnail plugin?

  32. mirc says:

    I want to use this plugin but it isn’t working. When is select to show only posts from the last week, it count’s all posts (also older).

    Mirc yukle

  33. Daniel says:

    Is it possible to exclude multiple categories?

  34. HoopersX says:

    I’m trying to find a tutorial to understand what the Child UI class does but I can’t seem to find a link.

    All I really want to do is bold the text. Is there a simple way to do that?

  35. Guys does anyone know how I can make this show more popular posts?

  36. Anonymous says:

    Is this plug-in still maintained? I’m looking for a way to list the most populair posts in terms of views. Is this a feature that we can expect in the future?


  37. Miguel says:


  38. Sergio Rey says:

    add to show the thumbnails in this widget? I have created a new check box in the menu.
    ‘images’ => ‘ checked’,
    $images = esc_attr($instance[‘images’]);
    $instance[‘images’] = strip_tags($new_instance[‘images’]);
    //display thumbnails
    if ($instance[‘images’] == ‘checked’){

    // How i load the thumbnails of each post? The_post-thumbnail doesnt work,


  39. Abcd says:

    hey, nice to meet you

  40. Enstine Muki says:

    Thanks for this plugin.
    It’s just what I was looking for. I’m going to try it right away

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Twitter: wesgood