Sunday, December 4, 2011


Shuffle Blogger Popular Posts

Blogger's popular posts gadget is a great way to introduce more interesting topics in your blog to an occasional reader. The gadget uses blog statistics, and the most popular post (from the chosen period or all time) is displayed first, second popular is second, etc.

The gadget is really great, but I missed some features. If you have always the same list in the same order in your sidebar, users very quickly ignore it. But if you shuffle the entries, the list looks fresh every page load. And I could not tell, which one of my most popular posts is the best, they are all good ;) and so random order suits them better.

So my first hack (more coming along) for the Popular Posts gadget randomizes the order of the popular posts. You can install this by adding extra HTML/Javascript gadget in your sidebar or paste the code to an existing gadget (the gadget must be after the popular posts gadget!), or you can put this code in your template html, just before </body>.

Data provided by - Download Raw

I use a simple but effective Fisher-Yates/Knuth shuffle to shuffle the posts. You must have jQuery loaded in your page for the code to work. If the script did nothing to your popular posts list, try adding the following code, which loads jQuery, in your template before </head>:
<script src='' type='text/javascript'></script>
I'm very pleased with the result of the hack, and hope you like it, too. You can see a working example of this in my MS-potilas blog ("Popular Posts" is "Suositut artikkelit" in Finnish), and later I'll install this also on YABTB (now installed).
[Hide comments] - [Show comments]
Click on a single comment to hide/show its text


kawsar said... [reply]


by the way do you know the blogger popular post html code

i want to put it on post page but blogger only allows widgets without giving you the code


MS-potilas said... [reply]

At this point it is not possible to display popular posts in any other way than using the widget. There has been a feature request here to expose the popular posts as a feed.

JeLBee Hub said... [reply]

Can i change the code orderby=published to random or popular post

Music Cover

MS-potilas said... [reply]

@JeLBee Hub
No, that's not possible. Popular posts cannot be fetched from feed, and Blogger feeds cannot be ordered randomly (but javascript can randomize the order of the results). It would be great to have the popular posts feed, with more than 10 entries. Maybe some day. :)

Michael G said... [reply]

Hi, thanks for the hacks on popular posts!
I am looking for a way to display popular posts by label (category), so in each label (or category), there is a unique list of popular posts only for this label (or category).
Did you try this?
Hope you can share this if you success, thanks in advance!

MS-potilas said... [reply]

@Michael G
Hi, I'm afraid it is not possible, or at least I don't know how to do it. My hacks only handles posts the popular posts gadget outputs. Currently the gadget does not support fetching popular posts by given label, and there is no other way to retrieve lists of popular posts in blogger.

Audrey Cramer said... [reply]
This comment has been removed by the author.
Audrey Cramer said... [reply]

I've tried using this on my blog several times and it didn't work. I finally found out why. Blogger has changed the div classes up a bit. You need to edit the code above to show .Popular-Posts instead of .popular-posts in the JavaScript and it will work. Thanks for the hack here.

Post a Comment

Related Posts Plugin for WordPress, Blogger...
See the hack
for this dynamic
views icon: