Add A New Random Post List Gadget To Your Blog




| 8 comments

new random posts gadget blogThis post has been rewritten on 22-09-10 to include a new improved random post gadget.The previous gadget had stopped working.Thanks to Sylvia from Classical Bookworm for the heads up.

Most blogs have Recent Post and maybe Popular Posts gadgets in the sidebar and footer and these help keep readers on you blog and display some of  your best posts.But only the random posts gadget really digs deep into your archive and helps keep those old posts rotating.Adding the Random Posts Gadget will only take a minute so lets look at the steps.

Add A Random Posts Gadget To Your Blog

Step1. In your dashboard click 'Design' > 'Add A Gadget'

Step 2. Choose Html/Javascript Gadget and paste the following code into the area provided :

<a href='http://www.spiceupyourblog.com'><img alt='Best Blogger Tips' src='http://3.bp.blogspot.com/_rKG-ziTSNUQ/TQ5eV0U0EiI/AAAAAAAACik/xo2eFaDbfrE/s1600/best+blogger+tips.png'/></a><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>

Note : You can change the number in red to choose how many posts you wist to have displayed.

Step 3. Give the gadget a title, Like : 'Random Posts', 'Posts From The Archive' etc.. Save The Gadget.


You have just added a cool new way for people to navigate your blog, make sure to check out some more great Blog Gadgets you will love !

Comments And Questions Welcomed Below.


Join over 5000 Subscribers! Please sign up to receive Updates.

SUYB has its Focus on Quality. If we post Crap, you can unsubscribe.

No Spam and No Garbage! - Use RSS, Twitter & Facebook as an Alternative


If You Enjoyed This Post Please Take 5 Seconds To Share It.

8 comments:

  1. Hi is there anyway it can be make into a table of some kind?

    ReplyDelete
  2. @ Dan Angel - It is in a list format you could probably set a width and height for the list to have it break into two columns.Is that what your looking for ?

    ReplyDelete
  3. Hi there Paul. Any way to change the picture for this button? And as much as I love your blog, I'd also appreciate a way to click it without going to yours!

    ReplyDelete
  4. i want to ask that if i add this gadget then i should delete popular posts widget or not?

    ReplyDelete
  5. @ syed tihaam ahmad - It's up to you or if you have room for both on your blog.

    ReplyDelete
  6. Hi!
    This is exactly waht i was looking for. thanx.
    (i think i over-use your blog)

    @ syed tihaam ahmad i don't think u need to remove the popular posts gadget. from what i understand, the popular posts gadget will show the posts getting the most hits while in our case, the random posts gadget will show a random list of old/archived posts u've already written, keeping them relevant.
    I'd advise keeping tem both.
    but that's just my opinion ;D

    ReplyDelete
  7. Works like a charm...thanks Paul. You are the best

    ReplyDelete



Important - If you ask a question make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.


Hire Us