Most Popular Posts

I’ve just added a new plugin to the site that lists the most popular posts on your blog.
The command is {popularposts} which creates an array, $pposts, containing the list of posts. Unfortunately it’ll only work if you use the newer $blogid/archives/p/1/ type url, not the old $blogid/archives/m/200407/#1
Thank you Nargler for the MySQL substring_index code. Helped a lot!

Here’s an example usage:

{if $pposts != ''}
  <b>Most Popular Posts</b><br />
  {foreach from=$pposts key=key item=hits}
    <nobr><a href="{$siteurl}/archives/p/{$hits.postID}/c/1/more/1" title='{$hits.title}'>{$hits.title|truncate:30:"..."}</a>: {$key}</nobr><br />

Author: Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

1 thought on “Most Popular Posts”

  1. hi there. im lookin’ for something like this, but will need a bit more info to get it running. can you help me? are you on IM? do i need to download the plugin you mentioned or is that code snip the whole thing? thx, kk+

Leave a Reply