WordPress.com Popular Posts
WordPress.com Popular Posts integrates with Wordpress.com Stats plugin, providing a widget to show the most viewed posts.
Installation
- Install Wordpress.com Stats plugin (required at least v1.2!!!)
- Download Wordpress.com Popular Posts v1.1.2
- Extract the files in the .zip archive, and upload them (including subfolders) to your
/wp-content/plugins/directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Place the widget where you like in your sidebars
- Enjoy!
Themes Integration
If your theme supports widgets, you can place the widget named ‘Popular Posts’ where you want.
If it doesn’t, put this code inside the file sidebar.php, in your theme files:
Optionally you can add some parameters to the function, in this format:
name=value&name=value etc.
Possible names are:
- title (title of the widget, you can add tags (e.g. <h3>Popular Posts</h3>) default: Popular Posts)
- number (number of links shown, default: 5)
- days (length of the time frame of the stats, default 0, i.e. infinite)
- show (what you want to show; it can be: both, posts, pages; default is both)
- format (the format of the links shown, default:
<a href='%post_permalink%' title='%post_title%'>%post_title%</a>)
You can use these special markers in the format value:
%post_permalink%the link to the post%post_title%the title the post%post_title_attribute%the title of the post; use this in attributes, e.g.<a title='%post_title_attribute%'...%post_views%number of views
Example
If you want to show the widget without any title, the 3 most viewed articles, in the last week, and in this format: My Article (123 views) you will use this:
<?php WPPP_show_popular_posts( "title=&number=3&days=7&format=<a href='%post_permalink%' title='%post_title_attribute%'>%post_title% (%post_views% views)</a>" );?>
Changelog
- 1.1.2 - Added a fix for a bug in WordPress Stats.
-
1.1.1
- Fixed some unclosed tags, which caused issues in IE7 configuration of the widget.
Removed (actually it's only skipped, not fixed yet) a nasty MySQL error if there aren't any "top posts". - 1.1 - New feature: now you can choose to show only posts, only pages, or both (default).
- 1.0.1 - Added CSS class "wppp_list", so that you can now customize the styling in your stylesheet.
-
1.0
- Feature: now you can customize the format of the links (see docs above)
Feature: it's now possible to show the number of views of the post (see docs above)
Fix: fixed utf-8 encoding issue with WP >= 2.5
Fix: now the widget should better integrate with your theme
Change: Note: the way to call WPPP_show_popular_posts() to integrate the plugin in non-widget-ready themes has changed. See docs above.
License
Wordpress.com Popular Posts is released under a GPL v3 license.
If you like this plugin, then buy me a coffee!![]()

I upgraded to wordpress 2.5 yesterday (and installed the WP stats plugin), and installed this plugin today. I followed all these steps, and added the widget to my sidebar. Yet it doesn’t show up! Could this be because there isn’t enough wordpress stats data for the widget to cull (less than 24 hours since upgrading the wordpress software), or is it just not compatible with wordpress 2.5?
Hi
If you open your dashboard, under Blog Stats, then click on “Top Posts & Pages”, and summarize by “All time”, is your list empty? In this case, you should wait for wp-stats to update its logs.
This blog is powered by Wordpress 2.5, so that shouldn’t be the cause of your issue.
What version of Wordpress.com Stats are you running? I have v1.2, and seems to work fine.
Also check in the widget options that the number of posts is set to a value (for me it’s 5).
Thanks for the quick reply! It looks like the problem was that I was using v1.1.1 of Wordpress Stats. I switched to v1.2 and it started working immediately. Thanks again!
What plugin do you use for allowing users to edit their comments? I love it!
Great! I’ll add the requirement of wordpress.com stats v1.2 to the FAQ. Thank you for reporting.
The plugin to edit comments is WP AJAX Edit Comments, really useful.
See you soon!
Hi, is there a way of inserting “popular post” to sidebar.php without widgets enabled?
Yes, add this code where you need:
<?php if (class_exists('WPPP')) WPPP::init(); ?>.I’ll add it to the docs.
Please ignore my previous comment.
Grab version 0.2.2 of Wordpress.com Popular Posts, then add this code where you need:
My apologizes.
Wow, That was fast. Many thanks!
Hiya - loving your work on this plugin - really handy way of helping people navigate the site.
Is there any way I can restrict the popular posts to, say, the past week or month for example?
Also, is there any way of excluding pages and just counting posts?
Reckon these would make really useful additions to a great plugin.
Chris
Thank you for your suggestions!
They will be added in next version.
Nice one - thanks for the fast reply!
quote
“Also check in the widget options that the number of posts is set to a value (for me it’s 5).”
unquote
How can I set the number of post if I got a themes that disable widget? any code for that?
and what plugins did you used for this comment smilies… love it… 
Hmmm, yeah I forgot about that.
I’ll add new arguments in the function “WPPP_show_popular_posts”, in next version.
The plugin for the smilies is Smilies Themer Toolbar, developed by me
you can find it here!
thanks…
I think this popular post plugin makes my IE error loading my website… Got no prob with FireFox though…
@JunkieYard Dot Com: now in version 0.4.0 you can add arguments to the function WPPP_show_popular_posts(), download the new version and read the docs above.
I’ll look into your error with IE.
Hi
very nice plugin, but is it possible for me to add number of post views in front of the list of most view posts?
Hi, added to wishlist.
its reaally great.. i searched very long time. i find it. thank for your work..
Excellent Plugin!
I do have a suggestion tho for it. When I tried to install it on my blog, it changes the formatting for the title of the sidebar. Where it says Popular Posts it is aligned left and different text than my normal sidebar. Is there a way to change some formatting on it so it looks like the rest of my sidebar titles?
@Eagle: implemented in v1.0
@iJohn: it should be fixed in v1.0. Now it is formatted by the theme. Let me know if it did the trick
Thanks for this plugin. It’s working great.
I am having some troubles with customizing the formatting to match the stylesheet of my theme. When I call the function in my sidebar.php file, are the results returned with a tag or something? I seem to have a bullet point associated with each popular post item that I can’t seem to get rid of.
Thanks for your help,
J.
Hi!
Actually, every link is part of an unordered list:
So, you must follow these steps:
- download and install latest version, v1.0.1 (that addresses your issue)
- add something like this to your style.css file (in your theme folder):
to remove the bullet.
(just tried on your site, with firebug, and it does the job).
If you know some CSS, you’ll be able to fully customize it.
Enjoy!
Huh? What kind of comments?
@frasten: Thanks! The information about the wppp_list class is exactly what I needed. It’s working great now - and I customized using CSS. All the best, and thanks again for the fast response.
I activated the plugin, but when I go to wp-admin/widgets.php to add the widget, I got this error:
Fatal error: Only variables can be passed by reference in ~/public_html/wp-content/plugins/stats.php on line 548
WordPress.org 2.5.0
WordPress.com Stats 1.2.1
Hi, it’s a Wordpress.com Stats issue.
However, I looked at the code, and this happens when you have a corrupted stats cache.
To fix it you have to manually execute (via phpMyAdmin or similar) this query, in your WordPress database:
Next time you reload the page, the cache will be re-created and it should work as expected.
that time I check this page, I couldn’t see the comments, but now I have them,
by wish list you mean, you gonna add it later, or we have now, and just need to do some configuration?
thanks alot
frasten, after I delete stats_cache, I got the widgets.php to work, but after I added the widget to a sidebar, the error returned. I had to disable the plugin.
@Eagle: the wishlist is a feature request list that I keep.
However your request was implemented in v1.0.
To put the number of post views you can customize the widget options, changing the format to something like:
<a href='%post_permalink%' title='%post_title%'>%post_title% (%post_views%)</a>@Lealcy B. Junior: something must be wrong with your installation of Wordpress.com Stats.
Your cache gets broken every time it is recreated.
Try to contact the authors at http://andyskelton.com and/or http://blogwaffe.com.
Yes, I think so. Any directions?
It works, you are gr8
thanks alotttttttttttttttttttttttttttttttttt
@Lealcy B. Junior: let’s try this:
edit the file stats.php, in the Wordpress.com Stats Plugin folder, and change line 543:
to:
and re-upload your wordpress.com stats plugin.
This could be a workaround; however if your blog receives many visits this could use some bandwidth (if your cache doesn’t work, it makes a requests to wordpress.com servers, on each visit).
I was with this same problem. But now it is ok. Thanks for share this excellent plugin.
[...] WordPress.com Popular Posts [...]
This is a really great plugin - thanks!
Any idea when you might update it to be able to exclude pages? I want to show only popular posts without pages being shown also…..for example, my “Home” page always shows up…
Thank you!
@Trisha, @Chris: Right now!
download v1.1 above.
It’s a little hackish, but it should work fine.
Nice plugin. It works great.
This is a great option if you have WP-Cache installed and wanted functionally like WP-PostViews.
But one thing I’m missing, is to show the views for posts by category. How can I do that ?
YAAY! It works! I’m so happy! I’m off to pay you a donation!
frasten you should let people donate more than just the price of a cup of coffee - I wanted to send you more but it wouldn’t let me change the amount - I’ll come by in another day or so and buy you another cup!
Thank you!
I really appreciated your donation, I’ll keep on working on these plugins!
And I edited the link for the donations, thank you for reporting.
Brilliant, brilliant, brilliant - well done. Exactly what I wanted. I’ll be winging you some cash on Paypal when I get five mins to sort. Top man.
I tried to get this plugin to work but whenever I go to add it in the widget section it just dissapears after I click “Add”. I have not upgraded to wordpress 2.5.1 yet is that needed to get it to work?
[...] also put a “Popular Posts” list on the sidebar. [...]
@Andy: Hi, what version of WordPress are you using? It’s a very strange behavior.
I am using wordpress 2.5 and I have wordpress.com stats version 1.2
I just tried it again and what seems to happen is after I click “add” popular posts widget under Available Widgets all the widgets under “Current Widgets” dissapear including the Popular posts one. They do not return unless I refresh the page and this all happens again if I try to add Popular posts every time but does not happen if I try to add other widgets. Its strange.
Sorry for my third post in a row but I thought I would tell you the good news that I got it to work! It turns out it was a browser bug! The Popular Posts widget would not add itself to the Current Widgets in IE7 but worked fine in Firefox. So the plugin is working fine on my site now!
Hello,
I have the most recent version of both this plugin and the stats plugin and everything seems to be setup correctly.
Unfortunately, no matter what nothing populates
When I add the widget it just lists the title but doesn’t list naything else - could it be my theme?
Any ideas? Thanks!
Actually, this just now popped up in the place of popular posts:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near — it won’t let me post the code error here…
Pretty weird, huh? Any suggestions? Thanks!
@Andy: Thank you for reporting. Actually, the widget configuration under IE7 looks really crappy.
I’ll look into that.
@ComicNerd.com: I’ve PMed you, I need the complete MySQL error.
hi, thank you for this great plugin, im wondering, is it possible to make some popular lists using categories with this plugin ?
Hi,
I was getting the same fatal error described by Lealcy B. Junior. The solution you supplied him works for me as well.
But I’d like to suggest you to work on a general fix. My WordPress (2.5.1) and your plugin (1.1.1) should work fine in all cases.
BTW your plugin is a nicely done job. Gongratulations.
@Steker:
Can you please elaborate on the feature you requested?
@Marcelo:
I’ve contacted the WordPress Stats authors, but I haven’t received any answers.
So, like you suggested, I’ve included in v1.1.2 a temporary fix for that error.
Great!
Does it mean I can undo the changes on stats.php?
@Marcelo:
Yes. Actually, the fix in v1.1.2 is the same as what you changed in stats.php.
It doesn’t harm, but you can safely remove the fix, because it is already included in Wordpress.com Popular Posts.
@Marcelo:
The authors of Wordpress.com Stats will include the fix in the next version of Wordpress.com Stats, as you can read in the development branch log.