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.
Donations
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.
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?
thankyou.
@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.
Hi,
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?
http://www.onlinemarketingrant.com
Thanks,
Brook
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!!!
Brook
Perfect plug-in and works without problem. Thank you very much.
@Brook Lenox: I’ll look to get another tutorial online shortly. Thanks for the comment!
Thanks for the post
Hi, Can it be most viewed page or post?
good plugin, i like it.. thanks
Thank you, perfect plug-in.
thank you for sharing
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?!
xo
— Mtte.
@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.
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.
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 🙂
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: 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.
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?
thanks
@steve: Not currently, but I’ll add it to the list of upgrades for the next version.
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.
Thanks.
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.
thanks
@Jim: I am indeed. The last day I updated it to work with WP 3.0 and will release it tomorrow or Tuesday.
thank you ju amst gorry!
Hello,
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?
@Andrew: I’ll look into it.
Hello,
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)”.
Hi there,
Is there a way to change titles from H2 to H1??
Thanks!
@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.
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).
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
is there any way to make this widget displaye the post thumbnail generated by simple post thumbnail plugin?
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
Is it possible to exclude multiple categories?
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?
Guys does anyone know how I can make this show more popular posts?
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?
Thanks!
Hola
Nice plugin
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,
}
Thanks.
hey, nice to meet you
Thanks for this plugin.
It’s just what I was looking for. I’m going to try it right away