Pages

Monday, December 12, 2011

3

Shuffle and limit popular post gadget post count

First look at these two previous articles about customizing popular posts gadget:

Shuffle Blogger popular posts and
Excluding specific popular posts in Blogger.

If you exclude posts from popular posts gadget, then you don't have exact count of popular posts – the count depends on how many excluded posts were in the list.

With this hack you can shuffle and then limit the count of popular posts. If you already have installed the shuffle hack, replace it with this code. You can put this code in a HTML/Javascript gadget, or in html template before </body>.

Data provided by Pastebin.com - Download Raw

This hack is installed on this blog, I use 10 popular posts, from which I exclude the current post user is viewing, and some others. Then the list is shuffled and limited to 8 entries. Modify the popcount variable in the script to get a different amount of posts. In my MS-potilas blog I use five popular posts, picked from ten posts minus some possible excluded posts.
[Hide comments] - [Show comments]
Click on a single comment to hide/show its text

3 comments:

Unknown said... [reply]

I am currently excluding some posts, but when I do that, the popular post gadget also exclude the number of posts. You said that this html will fix that, so that '8' is for the number of posts I want? or is part of the code?
BTW, Thanks Very Much for the help you have provided me, I appreciate that a lot. :)

MS-potilas said... [reply]

@Jose Ponce Yes, this is for displaying (in randomized order) a limited count of posts, which is useful if some posts are excluded. In line:

var popcount = 8;

change the number 8 to number of posts you want.

Thank you for your compliments. :)

Jcmaster said... [reply]

Hello, i want to thank you for your help, my popular posts widget was acting strange and adding posts outside the widget frame, it only holds 9 thumbnails and with this i can limit it so it wont show more posts outside its frame

Post a Comment

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