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, 2008 * Initial release

v1.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.

{ 141 comments… add one }

  • Gajogeje February 5, 2010, 8:34 am

    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?


  • wesg February 11, 2010, 7:51 pm

    @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.

  • Brook Lenox February 12, 2010, 6:52 pm


    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?



  • Brook Lenox February 12, 2010, 6:58 pm

    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!!!


  • dilek February 15, 2010, 5:00 am

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

  • wesg February 16, 2010, 11:40 am

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

  • bayrakci March 10, 2010, 9:24 am

    Thanks for the post

  • forma March 14, 2010, 3:48 pm

    Hi, Can it be most viewed page or post?

  • Karin March 20, 2010, 2:10 am

    good plugin, i like it.. thanks

  • kenneth March 21, 2010, 9:59 am

    Thank you, perfect plug-in.

  • bayrakçılar March 28, 2010, 7:41 am

    thank you for sharing

  • miette April 21, 2010, 6:02 pm

    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.

  • wesg April 21, 2010, 6:52 pm

    @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.

  • mike duran April 23, 2010, 7:39 am

    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.

  • Hikari May 29, 2010, 1:43 pm

    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 :)

  • biber hapı June 3, 2010, 6:28 am

    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.

  • wesg June 6, 2010, 6:03 pm

    @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.

  • steve June 24, 2010, 1:24 pm

    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?


  • wesg June 24, 2010, 1:38 pm

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

  • Kermit Woodall June 27, 2010, 11:27 am

    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.


  • Jim July 11, 2010, 4:52 pm

    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.

  • wesg July 11, 2010, 10:00 pm

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

  • mirc indir July 14, 2010, 1:28 am

    thank you ju amst gorry!

  • Andrew July 15, 2010, 2:29 pm


    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?

  • wesg July 15, 2010, 2:38 pm

    @Andrew: I’ll look into it.

  • Andrius July 19, 2010, 3:15 am


    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)”.

  • Cintia July 23, 2010, 12:56 pm

    Hi there,

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


  • wesg July 29, 2010, 1:48 pm

    @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.

  • mirc August 13, 2010, 5:16 pm

    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).

  • Stephanie M. Cockerl August 24, 2010, 10:49 am

    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

  • manu3l9816 August 31, 2010, 12:43 am

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

  • mirc October 1, 2010, 9:31 am

    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

  • Daniel December 23, 2010, 2:50 pm

    Is it possible to exclude multiple categories?

  • HoopersX June 1, 2011, 4:57 am

    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?

  • Spyros Klaoudatos June 5, 2011, 4:26 pm

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

  • Anonymous June 22, 2011, 5:47 pm

    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?


  • Miguel July 10, 2011, 12:28 am


  • John February 19, 2012, 10:04 am

    Nice plugin

  • Sergio Rey April 11, 2012, 3:29 pm

    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,


  • Abcd May 14, 2012, 9:44 pm

    hey, nice to meet you

  • Enstine Muki February 9, 2013, 3:37 am

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

Leave a Comment

Next Post:

Previous Post: