How to add a Random Post Widget to Blogger blog

Leave a Comment

For bloggers, traffic is the ultimate goal. Getting more traffic is always important for bloggers. If your blog has a high ranking in search engines, you will get good traffic from Search engines. But what about bounce rates? Bounce rates are those who comes from search engienes to your specific blog post,
Add-Random-posts-widget-to-blogger
 consumes your content and leave; not bothering about what else are there in the blog.
 If you are using a simple design in your blog and have very less links visible to contents 
 of your blog, then you have a high chance of loosing your readers so early. If you can showcase your blog contents wisely and properly, then you can reduce the bounce rate of your blog to a great extent. To showcase your blog posts, you can use various techniques like placing link on the navigation bar, in the sidebar, placing tag list or tag cloud etc.
 A very interesting and useful way is to place a 'Random Posts' widget to your blog. You may place the widget into sidebar or any place of your convenience and showcase the
 Random Posts you have made on your blog. 'Random Post widget will show the posts titles with a brief summary of the post in the widget. This particular widget will show 5 Random Posts on your blog. You can customize the number of posts and may increase the number or reduce according to your choice. When your visitor see the Random Posts and if he/she finds something interesting, then he/she will not leave you blog without clicking on that item and having a look into it. So, you are keeping your visitors engaged to your blog as much time you can.
Ok, no more boring descriptions. Let me proceed with the steps to add a Random Posts widget to your blog.
Step I: You already know that you have to log into your blogger account and go to the particular
 blog Dashboard where you want to add the widget.
Step II: Now, click on Layout. Add an HTML/Javascript gadget. It is advisable to add the gadget to the
 sidebar if you are using a layout which have a sidebar. Else you can add anywhere you find convenient.
Step III: Copy and Paste the following code in the code snippet to the HTML/Javascript widget.
Step IV: Save Your Gadget. Arrange you gadget to the place where you want to display the Random Posts.
 Click on 'Save arrangements'.
You are done. Now open your blog in a browser to check if it is working or not. If you have any query or 
advice, please feel free to comment below. Share us if you are benifitted. Thanks.


<style type='text/css'>
#tb-random-posts img{float:left;margin-right:10px;border:1px solid #999;background:#FFF;
width:36px;height:36px;padding:3px}
</style>
 
<ul id='tb-random-posts'>
<script type='text/javaScript'>
var rdp_numposts=5;
var rdp_snippet_length=150;
var rdp_info='yes';
var rdp_comment='Comments';
var rdp_disable='Turn off comments';
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'>
function random_posts(json)
{a=location.href;y=a.indexOf('?m=0');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){var rdp_commentsNum=entry.thr$total.$t+' '+rdp_comment}
else{rdp_commentsNum=rdp_disable};if(entry.link[j].rel=='alternate')
{var rdp_posturl=entry.link[j].href;if(y!=-1)
{rdp_posturl=rdp_posturl+'?m=0'}
var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry)
{var rdp_thumb=entry.media$thumbnail.url}
else{rdp_thumb=
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgybA-eXGcg73LsUUmcNrz_BJsDbLuwfUZtgnYyA6DjXVMrz4Qku1K5bIAWCjraGQqB7QERTMbOEjgWonGTF81H4AQLOD3rqWQSDw8jeyeVT0vP1aL_S0Hwft43GfrNQNmn0OdnpiluKOpd/s1600/no-image.PNG"}}};
document.write('<li>');
document.write('<img alt="'+rdp_posttitle+'" src="'+rdp_thumb+'"/>');
document.write
('<div><a href="'+rdp_posturl+'" rel="nofollow" 
title="'+rdp_snippet+'">'+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>
</ul> 

0 comments:

Post a Comment