WordPress Hack – Displaying Popular Posts
12 Feb
On my quest to improve this blog, I just added a way of keeping track of how many views each post has, as well as a list of the most viewed (see the footer).
I followed a tip from Pedro (blog in Portuguese) and went for the WP-PostViews plugin. It basically adds a couple of fields in the database and some functions to update each post’s view count and display it.
The installation is very easy. It’s all explained here, including how to use it. Basically: install (you can use the WordPress auto installer), activate, and then add a snippet of code wherever you want the info displayed.
<?php if (function_exists('get_most_viewed')): ?>
<ul>
<?php get_most_viewed(); ?>
</ul>
<?php endif; ?>
That’s the code to display the most viewed posts. You can also display the least viewed and the count for each individual post.
More plugins can be found from the same guy who did this one, Lester Chen. I might take a look at them in the future, there seems to be some neat stuff there.

Recent Comments