Quite some time ago, I started displaying a list of popular posts in the sidebar. At first, this was done manually and included what I considered to be my favorite posts. After I while, I noticed that this list was a bit outdated and decided it was time to update it. But instead of simply modifying what was there, I wanted to create a dynamic list of what users considered the most popular posts (based on the number of times viewed).

Unfortunately, this is not a built-in feature of WordPress. Undaunted, I delved into the list of plug-ins listed on the WordPress site. It didn’t take long to find one called WordPress Popular Posts v2.2.1, written by Héctor Cabrera.

Simply upload the plug-in, activate it, alter a few settings, and add a snippet of code where you want the list to be displayed. Very easy and it works great. What it does is add a table to the database and then add a record each time a page is viewed. Then, statistics can be generated through simple SQL queries (This is all done by the plug-in; users do not need to know how to use SQL).

Immediately, I noticed that static pages (contact, about, downloads, etc) were dominating the list. These aren’t actually “popular”, they are just heavily used. The plug-in has a checkbox that allows pages to be ignored. I checked that and now only posts will be counted.

It didn’t take long to see that certain posts were miles ahead of the others and firmly took hold of the top few spots. Nothing wrong with this, per se, but part of the objective was to spotlight older posts that deserved better than to disappear into the archives, not just a select few.

Therefore, last night I changed the list to show the top 10 most viewed posts in the previous 24 hours (it was showing the top 10 most viewed of all time).

But sometimes users may want to see more than just the top ten. I didn’t want to take up any more space in the sidebar, so I stole bits of code from the plug-in in order to create a page that will show the top 50 instead. There is now a “[More]” link that pulls up that page.

The plug-in allows viewing Daily (previous 24 hours), Weekly (previous 7 days), Monthly (previous 30 days), and All-Time statistics. Now that I have a page that displays a Daily listing, it’s a simple matter to expand that in order to show the others. It seemed silly not to, so I added them as well and created buttons in the sidebar to bring them up.

Initial page stats show that they are being used so I guess it was worth doing. Hope you like it.