Wednesday, July 25, 2012

How to Add Random Post Widget To Blogger Blog

Author: Gagan Masoun
How to Add Random Post Widget To Blogger Blog
All bloggers know very well that "Related Posts widget" and "Recent Posts widget" are necessary part of any blog, but some times readers usually do not mind reading some quite-unrelated posts too.If you want to increase the number of page impressions then this widget might help you a lot.

The Random Posts Widget will show random posts from your blog. The main good thing about this widget is that it is loading pretty fast. Here is one step guide for this tutorial.

Random Post Widget To Blogger Blog

How to Add Random Post Widget To Blogger Blog

  • Go to Blogger Dashboard -> Layout -> Add a Gadget -> HTML/JavaScript
  • Paste The Following Code 
<script type="text/javascript">
var randarray = new Array();var l=0;var flag;
var numofpost=5;function randomposts(json){
var total = parseInt(json.feed.openSearch$totalResults.$t,10);
for(i=0;i < numofpost;){flag=0;randarray.length=numofpost;l=Math.floor(Math.random()*total);for(j in randarray){if(l==randarray[j]){ flag=1;}}
for(n in randarray){ var p=randarray[n];var entry=json.feed.entry[p-1];
for(k=0; k <; k++){if([k].rel=='alternate'){var item = "<li>" + "<a href=" +[k].href + ">" + entry.title.$t + "</a> </li>";
<script src="/feeds/posts/default?alt=json-in-script&start-index=1&max-results=1000&callback=randomposts" type="text/javascript"></script>
Note - The Number In "Red" Is The Number Of Posts to Be Displayed In Widget.


Post a Comment