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

Acknowledgements

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

Installation

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




Usage

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

Defaults

  • 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

Changelog

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 }

  • GTL Media August 6, 2009, 4:05 pm

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

  • Jason Beaird August 10, 2009, 11:06 am

    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.

  • Thomas August 10, 2009, 5:52 pm

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

  • Teknoloji haberleri August 11, 2009, 12:46 pm

    thank you admin

  • Onore August 14, 2009, 4:44 pm

    Simple and Great PlugIn – Thanks =)

  • Scott August 16, 2009, 2:06 pm

    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?

  • alienman August 16, 2009, 6:22 pm

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

  • Bayrak August 18, 2009, 5:22 am

    Thank you plugin

  • Sean James August 28, 2009, 10:26 pm

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

    http://potleetopw.net/

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

  • Tiffany September 3, 2009, 12:18 am

    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?

    Thanks
    Tiffany

  • Teknoloji Haberleri September 8, 2009, 8:19 pm

    thank you plugin supper

  • T.M. September 18, 2009, 8:11 pm

    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.

  • Steven September 19, 2009, 4:22 pm

    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?

    Thanks!

  • wesg September 20, 2009, 5:25 pm

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

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

  • ahmed September 21, 2009, 10:09 pm

    hello
    i need change stayle ?

  • chat October 1, 2009, 7:34 am

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

  • Gray October 5, 2009, 10:10 pm

    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?

  • bayrak October 12, 2009, 5:03 pm

    thank you for sharing Congratulations on a very beautiful designed site

  • Kenny Gor October 16, 2009, 1:18 pm

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

    please help. great plugin

  • BGLH October 19, 2009, 3:59 pm

    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?

    Thanks!!

  • Simon October 26, 2009, 10:27 am

    Hello,

    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.

  • Simon October 26, 2009, 10:39 am

    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

  • wesg October 26, 2009, 11:31 am

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

  • Kenny Gor October 28, 2009, 3:32 pm

    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

  • Kenny Gor October 28, 2009, 3:36 pm

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

  • e-okul October 30, 2009, 9:58 am

    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.

  • Anders Holm November 1, 2009, 7:50 am

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

  • wesg November 2, 2009, 11:51 pm

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

  • doug November 6, 2009, 10:20 pm

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

  • Reino November 8, 2009, 9:16 am

    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!

  • wesg November 15, 2009, 12:30 am

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

  • bayrakçı November 15, 2009, 7:17 am

    thamnk you very nice

  • Ninja November 22, 2009, 2:57 pm

    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?

  • wesg November 22, 2009, 4:34 pm

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

  • Ninja November 22, 2009, 5:17 pm

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

  • Battlefield 3 November 23, 2009, 1:34 am

    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 !

  • PG December 1, 2009, 6:06 am

    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

    PG

  • wes December 2, 2009, 6:23 am

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

  • Benjamin Rama December 2, 2009, 7:14 am

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

  • wesg December 3, 2009, 3:30 pm

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

  • Mark December 13, 2009, 12:38 pm

    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.

  • wesg December 13, 2009, 1:51 pm

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

  • Glenn December 18, 2009, 6:39 am

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

  • wesg December 18, 2009, 5:45 pm

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

  • sahibinden December 21, 2009, 9:45 pm

    thanks for article

  • Ben December 28, 2009, 11:32 pm

    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.

  • Tomi December 30, 2009, 3:52 am

    Hiya!
    It is worked on WordPress 2.9?

  • Hazel December 31, 2009, 6:34 pm

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

  • shoaib January 10, 2010, 2:36 pm

    nice plugin and most of all its really clean.thnx

  • bayrak February 2, 2010, 8:02 am

    thank you for sharing

Leave a Comment

Next Post:

Previous Post: