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;}}
if(flag==0&&l!=0){randarray[i++]=l;}}document.write('<ul>');
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>";
document.write(item);}}
}document.write('</ul>');}
</script>
<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

ProBlogger - Inspiring Others Realize Their Dreams!

Share this

Related Products

Related Posts

Previous
Next Post »

64 comments

Write comments
August 30, 2009 4:59 PM delete

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.


Martin

Reply
avatar
August 30, 2009 5:35 PM delete

Hello Martin,

Yes that is certainly possible, check out this page for a live example:
http://bloggerstop.net/2008/09/contact-us.html
(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 :)

Reply
avatar
August 30, 2009 7:18 PM delete

VERY VERY good widget, thanks a lot for this Divia

Reply
avatar
August 30, 2009 7:19 PM delete

I'll try to show images on the widget too if i got some time

Reply
avatar
August 30, 2009 7:24 PM delete

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.
Tq.
Brianpedro

Reply
avatar
August 30, 2009 7:46 PM delete

The link u give is a autoblogger...
watch closely,he has just taken the feedburner E-mail delivery and he is posting by mail..HE has not even removed unsubscribe in some posts....you should not encourage this type of .people...remove that do-follow link..u are encouraging a plagiarism blog.
see the title from the archive ..you will understand..

Original source is here
http://hack-genius.blogspot.com/2009/07/random-post-widget-for-blogger.html

Reply
avatar
August 30, 2009 10:44 PM delete

Sai Ramji Divya,

I was badly needing this widget. I will certainly use this widget.

Thanks a lot

Hetal Patil

Reply
avatar
August 31, 2009 12:03 AM delete

Divya Sai looks like the place you got it from was also a content stealer because theoriginal code is here Random Posts Blogger Widget. http://www.bloggodown.com/2009/04/random-posts-blogger-widget.html

Reply
avatar
August 31, 2009 1:03 AM delete

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

Reply
avatar
August 31, 2009 6:05 AM delete

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.

Martin

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


Sorry to stay off topic b

Reply
avatar
August 31, 2009 8:24 AM delete

@ Vinoth @ Gautam
Thanks a lot guys for directing me to the original source, I have just updated and corrected the post.

@Manish
Here's the tutorial (It'll solve an important SEO purpose too):
http://bloggerstop.net/2009/01/show-only-titles-in-blog-archives-with.html

@Martin
It's all free, simply register and start making your forms(you can make multiple forms), simply give it a try, I am sure you'll like their service.

Reply
avatar
August 31, 2009 8:35 AM delete

@ 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:
http://www.google.com/search?q=site%3Asinarhairan.blogspot.com

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.

Reply
avatar
August 31, 2009 10:37 AM delete

There are a lot of random posts gadgets out there, but yours is the one that works the way I want it to. Thanks!

Reply
avatar
DAF
September 02, 2009 12:54 AM delete

Hi.....THANK YOU ...........

Reply
avatar
September 02, 2009 10:08 AM delete

Anyway, blogger is the most customizable blog platform in the world. Do you agree with me?

Reza Winandar from Blogger Make Money

Reply
avatar
September 21, 2009 5:33 AM delete This comment has been removed by a blog administrator.
avatar
October 06, 2009 12:41 AM delete

Hi the widget works great! I have a question though. How do I change the color of the links? I have a dark background and the links appear dark and it is hard to see. Thank you for your time.

http://swwildspace.com/

Reply
avatar
October 06, 2009 9:54 AM delete

@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.

Reply
avatar
October 12, 2009 8:21 PM delete

Thank you very much for your help!

Reply
avatar
October 16, 2009 7:25 AM delete

Thanks for the post. I post this to mine.
http://csie-tw.blogspot.com/2009/10/bloggerrandom-post.html

Reply
avatar
February 11, 2010 5:07 AM delete

not working in my template.....

Reply
avatar
March 02, 2010 12:23 AM delete

thanks friend, its really work until now! nice 2 see u... ;-)

Reply
avatar
March 26, 2010 2:02 PM delete

This is a nice widget. Most of the other random post widgets around wouldn't work on my blog!

Reply
avatar
March 28, 2010 3:16 AM delete

Great Widget :D

thx useful

www.get2ware.co.cc

Reply
avatar
March 29, 2010 3:24 AM delete

This is great! It works perfectly in Chrome but it's not working for me in IE. Is that just me?

Reply
avatar
March 30, 2010 9:01 AM delete

THIS GREAT DUDE......

THANKS BRO!

Reply
avatar
April 12, 2010 11:50 PM delete

Hi amd thanx for sharing.
This widget works OK for me with Firefox, but does NOT work with Internet Explorer, nor with Chrome

Reply
avatar
April 16, 2010 8:31 PM delete

can you add www.consensus2012.com its a free customizable polling widget that delivers real time results

Reply
avatar
May 19, 2010 6:58 PM delete

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

Reply
avatar
OS
June 10, 2010 10:58 AM delete

best widget random pos 4 blogspot thx:(

Reply
avatar
July 04, 2010 9:35 AM delete

thanks alot for the script i really appreciate your work........good job..!!!

Reply
avatar
July 06, 2010 6:51 PM delete

That helped me a lot, you rock !!!

Reply
avatar
August 08, 2010 8:29 AM delete

thank you for this..

visit for free ebooks here http://dailyebookdownload.blogspot.com/

Reply
avatar
August 29, 2010 3:40 AM delete

Useful widget, I'm just looking for it.
Thx ;)

Reply
avatar
September 10, 2010 1:37 AM delete

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 :)

Reply
avatar
September 21, 2010 10:33 AM delete

Cool hack.... My blog looks cool with this widget ;;)

Reply
avatar
November 05, 2010 2:45 PM delete

Excellent widget - it's working perfectly.

One question: how can I change the html so it says "random post" instead of the episode's name?

Reply
avatar
November 16, 2010 7:02 AM delete

Thats attractive. and i want with thumbnail one,,

Reply
avatar
November 24, 2010 4:16 AM delete

The widget works fine in Firefox. In I.E., it works if I put the widget before Twitter Profile API. But if it is put after the Twitter, it doesn't work, means just empty. Any fix to this?

Reply
avatar
December 24, 2010 5:52 AM delete

can you tell us the code with thumnail random post

Reply
avatar
January 26, 2011 1:11 PM delete

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!!

Reply
avatar
January 26, 2011 1:56 PM delete

Yes you can do that (in fact not just a color background - but images as background too),
Although I have written the tuorial for popular posts widget, but you can do that for this random posts widget too....read it here:
http://bloggerstop.net/2009/02/new-customized-popular-posts-widget-for.html

Reply
avatar
February 08, 2011 11:29 PM delete

I Can't use this script,, it makes my firefox become not responding :(

Reply
avatar
February 21, 2011 1:30 AM delete

I just added this widget to my blog. You rock! :D

Reply
avatar
March 07, 2011 7:14 AM delete

hello...
i was looking for this widget.. this widget is not working on my blog...
my blog is www.kuchkhaashai.com
could you please help me out....

thanks...

Reply
avatar
March 07, 2011 1:16 PM delete

Hi Vijay, there's nothing much to edit or go wrong in this widget...it has been alreadu tailor made to fit in Blogger blogs.

Reply
avatar
RFT
March 29, 2011 8:54 AM delete

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.

Reply
avatar
June 22, 2011 5:39 PM delete

Thanks for sharing this. I am using this on my blog and it's working perfectly! :)

Reply
avatar
July 05, 2011 4:16 PM delete

thanks man i was really looking for this :D

Reply
avatar
G2F
July 12, 2011 9:51 PM delete

nice widget but more nice if with img view.
thanks for share

Reply
avatar
October 06, 2011 4:31 AM delete

No longer working. Please, update the script.

Reply
avatar
October 19, 2011 3:33 PM delete

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!

Reply
avatar
January 09, 2012 1:06 AM delete

Thanks for this, works perfectly fine.

Reply
avatar
February 23, 2016 12:55 AM delete

I post the script as u tell and i am able to solve the problem thanks sir

Reply
avatar

Comments are moderated on this blog

Allowed HTML tags: <b>, <i> and <a>

Comment Like This! and Optimize your blog EmoticonEmoticon