August 31, 2009

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


63 comments:

Martin said...

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

Divya Sai said...

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

LeBlogger said...

VERY VERY good widget, thanks a lot for this Divia

LeBlogger said...

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

LeBlogger said...

oh yeah i am very happy u decides to use the defaut Blogger comment form.

I see u are changing the comment section style, good luck

sinarhairan said...

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

vinoth said...

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

Ms Hetal Patil said...

Sai Ramji Divya,

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

Thanks a lot

Hetal Patil

gautam said...

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

Manish said...

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

Martin said...

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

Se7enTime said...

Thanks

Divya Sai said...

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

Divya Sai said...

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

billjac said...

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

DAF said...

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

Reza Winandar said...

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

Reza Winandar from Blogger Make Money

Mengembalikan Jati Diri Bangsa said...
This comment has been removed by a blog administrator.
Matt said...

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/

Divya Sai said...

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

Matt said...

Thank you very much for your help!

I am a programmer said...

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

bud 9k said...

thank it useful

gameboy said...

not working in my template.....

Arief Masqulin said...

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

Royston said...

Its perfect! thanks!

fairyhedgehog said...

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

Sai - Blogger Help said...

Glad it served your purpose :)

nickdotnet said...

Great Widget :D

thx useful

www.get2ware.co.cc

fairyhedgehog said...

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

Arez_Reza said...

THIS GREAT DUDE......

THANKS BRO!

Hendra Site @ hendra-site.com said...

Great post, thanks!!! :)

FRIENDS-PC said...

thank share

SkankyPunky said...

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

The App Spot said...

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

Witty Jester said...

Thanks bro!!!great widget

Robin said...

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

OS said...

best widget random pos 4 blogspot thx:(

jaganmangat said...

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

VidesiBlog said...

That helped me a lot, you rock !!!

ASHOK said...

Thanks Man!.

By,
Free Hacking Tricks

dailyebookdownload said...

thank you for this..

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

tesarn said...

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

Sanskar Shrivastava said...

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

Techpraveen said...

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

W. A. Silverblacks said...

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?

Ansen said...

Thats attractive. and i want with thumbnail one,,

Liau Kok Meng 廖国民 said...

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?

asif said...

can you tell us the code with thumnail random post

حامد said...

hi

StephanieC | Seriously? Really?? Seriously? said...

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

Sai - Blogger Help said...

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

Safe Code said...

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

Ping-i said...

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

Vijay said...

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

Sai - Blogger Help said...

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.

RFT said...

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.

Aris Moreno said...

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

NJ_9 said...

thanks man i was really looking for this :D

G2F said...

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

Open door to everyone... said...

No longer working. Please, update the script.

Nicotest said...

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!

Ryann @ IRPeX said...

Thanks for this, works perfectly fine.

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

comment on this post Share Your Views

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

Join and share your views with other bloggers at BloggerStop Community

Comment Like This! and Optimize your blog...

SPAMMER OF THE MONTH: www[.]TopRankLinks[.]com

Next Post Homepage Previous Post

Regular Readers


What They Say...

Divya Sai is the ingenious webmaster of Bloggerstop.Net. Divya is extremely patient, knowledgeable and responsive... Bloggerstop.net has an abundance of articles on creating widgets, templates, hacks and ways to make your blog search engine friendly.
- Stacey @Pets With Allergies
I stumbled onto a great site. Sai, over at Bloggerstop.net has helped me tremendously and with great patience...for any and all questions regarding computer issues. And again, THANK YOU Sai.
- Cheryl @Cmash Loves To Read

More Here...

Popular Posts

Get this widget

| © 2010 BloggerStop.net | Blogger Widgets | Template by Dicas Blogger | Enhanced By Divya Sai | Privacy Policy