The Best Random Posts Widget For Blogger Blogs

Although “Related Posts Widget” and “Popular Posts Widget” are important for all types of blogs, but in blogs where almost all the posts are similar (like blogs with articles on recipes, money-making, computer tricks or automobiles etc.), visitors usually do not mind reading some quite-unrelated posts too. So along with Related Posts widget, a “Random Posts widget” on your blog will help you to increase the number of page impressions.

Adding a Random posts widget is very easy…
Simply log in to Blogger, go to Layout, click on “Add a Gadget“, and select it as “HTML/JavaScript” type.

And finally paste this code in to it:

<script type=”text/javascript”>
var randarray = new Array();var l=0;var flag;
var numofpost=6;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 < entry.link.length; k++){if(entry.link[k].rel==’alternate’){var item = “<li>” + “<a href=” + entry.link[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>

Edit the code shown in ‘red’ to change the number of posts being displayed in the widget.
Now save the widget, and place it somewhere so that it is clearly visible to the visitors !

Thanks to Blog Godown for this widget. Visit this blog to display the same widget along with summaries.
Image credits: AndApps

63 thoughts on “The Best Random Posts Widget For Blogger Blogs

  1. Hi Mr Sai

    This is a little bit off topic, but I was wondering if you could help me with a query?

    Is there any way when building a site on the blogger platform to include within a post a "browse box"? Something where you anybody visiting the site could click on a browse button within the post and then can browse to a particular folder / file on their hard drive and upload a picture, word doc or other file?

    Obviously, if this can be done, any file uploaded would have to be able to go to some part of the web other than blogspot – is there functionality to call the file to a hotlink files or google sites account or similar?

    Thank you very much for any help you can give with this.


  2. Hello Martin,

    Yes that is certainly possible, check out this page for a live example:
    (see the second form-to send templates/any file to me)

    In one of my posts, I have given the instructions to add a contact me page to blogger blogs. So by using the same method, while creating your "Contact Form" select to show only "one field" in the form, which is a "file attchment" type. Once you register there and start creating your form, you'll understand what I am saying.

    But by this method, whatever files are uploaded by your readers will be mailed to you, so they will be stored in your mail-inbox, I hope that solves your purpose.

    BTW, nice private policy page Martin 🙂

  3. Dear Sai,
    I am having trouble with with my post that has not been updated since jun. When I check my blog status the last message appear like this.

    (Friday, June 12, 2009 Blogger will be unavailable Monday (6/15) at 12:00AM PDT for about 10 minutes for maintenance.)
    So what do I do to solve the problem because my blog list will not be updated to all my friends blog.

  4. Hi divya…

    Nice article….

    Actually i had some questions.. Slight off topic…sorry

    I have a blog at http://entrance-corner.blogspot.com/

    but the problem is whenever any one searches or clicks on the labels category….the results arent given in a proper way….

    u can check it out…try clicking on any labels….on my blog

    Please tell me how to modify the search results page in blogger….like yours…how you have done it…?

    i searched the whole "world wide web" but coulndt find any

    I request you to please post something related to it….or give me the solutions for it.. http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/2.gif

  5. Hi Divya

    Thank you for pointing me towards your own contact page and the e-mail me form website (I have previously used webformdesigner.com which does not provide captcha, nor the "browse box" function).

    Thank you too for your kind comments about my privacy policy!

    Sorry to stay off topic here but can you please clarify (because I cannot find the answer to this on the e mail me form website) – to build the form with that browse box, is that possible using the free service, or did you have to subscribe to one of their paid services?

    Thank you in anticipation of your help with this.


    The CV-Central sites are coming along nicely by the way!

    Sorry to stay off topic b

  6. @ SinarHairan

    Couldn't get your point…Your feed is working fine(as displayed in your "My Headlines" widget)

    Moreover all the posts are getting indexed too by Google:

    The Blog status message is actually not just specific to your blog, but it is for everyone hosted on Blogger. So don't worry about those messages, they are usually temporary and blogs go down for just around 10-20 minutes.

  7. @Matt

    In your template, you'll find this:

    .tabdiv li {
    list-style-image: url("star.png");
    margin-left: 20px;

    just below it, add this:

    .tabdiv li a {
    color: red;

    NOTE: Instead of "RED", you may use any html-hex code by adding the code with a # prefix.

  8. Fantastic! Thank you for sharing this… it seems easy enough to implement and seems slightly better than the plain "random post" link!

  9. I want to know is there any way to include a ticker like random post widget which will rotate or animate the blog posts title with the link to the blog post unlike feedburner's headline animator which links to the feed url. I hope you are understanding what I am trying to say. for e.g BBC news website here http://www.bbc.co.uk/news/ titled "LATEST"

    Thank You 🙂

  10. Hi there,

    Thanks so much for posting this widget and tutorial.

    It works like a charm on my blog.

    MY QUESTION to you is – can I make the background white? Right now the red titles are hard to read over the pixelated image I am using as a background.

    I see above how I can chang the colour of the text, but I don't see how to add a background or box around this random post widget.

    Many thanks in advance. Great, informative, helpful blog!!

  11. Thanks for this widget. I like it. I've used different one for random posts, but it somehow was making "traffic congestion" on my page…. This one is excellent… Thanks.

  12. Very good widget, thank you!

    It works very good in my public blogs, though it doesn't work in "closed" blogs, that is, those blogs in which only authors can read the posts. Even being signed in as author, the widget doesn't work.

    I doesn't work because the feeds are not available in this kind of blog.

    Is it possible to solve this problem?
    Maybe calling the feed in a different way?

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *