Wednesday, August 21, 2013

Add Premium Look Random Posts Widget To Blogger

Author: Gagan Masoun
Premium Look Random Posts WidgetRandom Posts widget helps to show random posts from your blog. You can add it to your sidebar or anywhere you want to show random post on blog. This Random Posts Widget shows post without thumbnails. You can give life to your old posts because every time your blog get refreshed it will show new random posts. Today in this tutorial we will show you how to add a random posts widget without thumbnails on your blog.


Random Posts Widget

How to Add This Widget To Blogger Blog

  • Go to Blogger Dashboard -> Layout -> Add a Gadget -> HTML/JavaScript
  • Paste The Following Code
<style>#random-posts{border: 1px solid #aaa;margin: 0px 0;-moz-border-radius: 3px;-webkit-border-radius: 3px;border-radius: 3px;-moz-box-shadow: 0 5px 5px -5px #999;-webkit-box-shadow: 0 5px 5px -5px #999;box-shadow: 0 5px 5px -5px #999;background: #f6f6f6;background: -webkit-gradient(linear, 0% 40%, 0% 70%, from(#f9f9f9), to(#f1f1f1));background: -moz-linear-gradient(linear, 0% 40%, 0% 70%, from(#f9f9f9), to(#f1f1f1));}#random-posts li{background: url(http://4.bp.blogspot.com/-L_LJEgujgIc/UhTU2lSmpFI/AAAAAAAA8lo/cX9ye62idwQ/s1600/tick_blogsdaddy.png) no-repeat 12px;border-bottom: 1px solid #ccc;font-family: cambria;font-size: 12pt;list-style-type: none;margin: 0;padding: 6px 10px 10px 3em !important;height: 44px;overflow: hidden;line-height: 1.5em;}</style>
<div id="random-posts">
 <script type="text/javaScript">
var rdp_numposts=7;var rdp_snippet_length=0;var rdp_info='no';var rdp_current=[];var rdp_total_posts=0;var rdp_current=new Array(rdp_numposts);function totalposts(json){rdp_total_posts=json.feed.openSearch$totalResults.$t}document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts\"><\/script>');function getvalue(){for(var i=0;i<rdp_numposts;i++){var found=false;var rndValue=get_random();for(var j=0;j<rdp_current.length;j++){if(rdp_current[j]==rndValue){found=true;break}};if(found){i--}else{rdp_current[i]=rndValue}}};function get_random(){var ranNum=1+Math.round(Math.random()*(rdp_total_posts-1));return ranNum};</script><script type="text/javascript" src="/feeds/posts/default?alt=json-in-script&amp;max-results=0&amp;callback=totalposts"></script><script type="text/javaScript">
function random_posts(json){for(var i=0;i<rdp_numposts;i++){var entry=json.feed.entry[i];var rdp_posttitle=entry.title.$t;if('content'in entry){var rdp_get_snippet=entry.content.$t}else{if('summary'in entry){var rdp_get_snippet=entry.summary.$t}else{var rdp_get_snippet="";}};rdp_get_snippet=rdp_get_snippet.replace(/<[^>]*>/g,"");if(rdp_get_snippet.length<rdp_snippet_length){var rdp_snippet=rdp_get_snippet}else{rdp_get_snippet=rdp_get_snippet.substring(0,rdp_snippet_length);var space=rdp_get_snippet.lastIndexOf(" ");rdp_snippet=rdp_get_snippet.substring(0,space)+"&#133;";};for(var j=0;j<entry.link.length;j++){if('thr$total'in entry);if(entry.link[j].rel=='alternate'){var rdp_posturl=entry.link[j].href;var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry){var rdp_thumb=entry.media$thumbnail.url}else{rdp_thumb="http://1.bp.blogspot.com/-44EergrPyEU/UhTU2eQARvI/AAAAAAAA8lk/CFBRyKaR3Ik/s1600/default.jpg"}}};document.write('<li>');document.write('<div><a href="'+rdp_posturl+'" title="'+rdp_posttitle+'">'+rdp_posttitle+'</a></div>');if(rdp_info=='yes'){document.write('<span>'+rdp_postdate.substring(8,10)+'/'+rdp_postdate.substring(5,7)+'/'+rdp_postdate.substring(0,4)+' - '+rdp_commentsNum)+'</span>'}document.write('<div style="clear:both"></div></li>')}};getvalue();for(var i=0;i<rdp_numposts;i++){document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts\"><\/script>')};
</script><script type="text/javascript" src="/feeds/posts/default?alt=json-in-script&amp;start-index=100&amp;max-results=1&amp;callback=random_posts"></script></div>

Customizations

  • The Number In "Red" Is The No. Of Posts to Be Displayed In Widget.
  • If You Want Then Replace "Green" Highlighted Color URL With Your Own Icon.
  • Save Your Gadget and Its All Done!
If you like this tutorial about "Premium Look Random Posts Widget" and wish to get more SEO Tips, Widgets then SUBSCRIBE TO OUR EMAIL SUBSCRIPTION!

7 comments:

  1. Well random post is very helpful for getting more traffic from it. So we must use it for our blogs.

    thanks for the awesome share.

    ReplyDelete
    Replies
    1. Yes, we can increase page views on our blog. It is very helpful widget.

      Delete
  2. Nice coding here Gagan. Using this gadget can help drive more traffic through your blog.

    ReplyDelete
    Replies
    1. Yes, Ryan we can generate a lot of traffic with the help of this widget. :)

      Delete
  3. dear this a awesome post. we can increase our blog traffic through this Good looking widget. and you describe that we can change color and number of post. I blue color. what your choice?

    ReplyDelete
    Replies
    1. My choice is same with your choice. Rana you should add this widget to your blog. It will work like a magic for you.

      Delete