Spice Up Your Blogger Blog with Custom Designed Templates - BTNT Services!

New Stylish Related Posts For Blogger Blogs

On By // 1 comment
Hi Friends!! Today, I present to you the "All New Stylish Related Posts Widget For Blogger/Blogspot Blogs".The main idea behind developing this widget is to increase our Adsense revenue, pageviews (primary reason for related posts widget) and to make our blog look more professional.

If you want to look at the earlier versions of the related posts widget posted on my blog, then visit the following links - Related Posts widget for blogger (based on Labels). The latest version of related posts widget comes with added features like "What's Next?" and  "Google Adsense".

Take a look at the screen shot below to preview the widget.
Are you excited with the widget shown above??? Want to add this  to your blog, then just follow the steps mentioned below. Please create a back up of your template before you install this widget.

To do this, navigate to "Design->Edit HTML" and make a backup of your template clicking on the "Download full template" link at the top. Once the back up is over, follow these steps carefully.
1. Expand your template, that is, make sure you have a tick mark in box next to "Expand Widget Template". Now, search using "CTRL+F" for the following line:
<div style='clear: both;'/>
2.Copy the code below. Paste the code just below the line you searched in step1.
<div class='cps'>
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-YOURADSENSECODE&quot;;
google_ad_host = &quot;pub-1556223355139109&quot;;
/* 468x15, created 10/15/10 */
google_ad_slot = &quot;2917101792&quot;;
google_ad_width = 468;
google_ad_height = 15;
&lt;script type=&quot;text/javascript&quot;

<div id='end'>
<ul class='actions'>
<h3>What&#39;s Next?</h3>
<li><a class='digg' expr:href='&quot;http://digg.com/submit?phase=2&amp;url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>Digg it</a></li>
<li><a class='stumble' expr:href='&quot;http://www.stumbleupon.com/refer.php?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>StumbleUpon</a></li>
<li><a class='delicious' expr:href='&quot;http://del.icio.us/post?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>Save on Del.icio.us</a></li>
<li><a class='subscribemini' href='http://feeds2.feedburner.com/EverythingAboutBlogging' rel='nofollow'>Subscribe via RSS</a></li>
<li><a class='comment' expr:href='data:post.addCommentUrl' expr:onclick='data:post.addCommentOnclick' rel='nofollow'>Leave a comment</a></li>
<ul class='tips'>
<h3>Other Recommended Posts</h3>
<li><div style='display:none;'><b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if><b:if cond='data:blog.pageType == &quot;item&quot;'>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name +   &quot;?alt=json-in-script&amp;callback=related_results_labels&amp;max-results=5&quot;' type='text/javascript'/></b:if></b:loop></div>
<script type='text/javascript'> removeRelatedDuplicates(); printRelatedLabels(); </script></li></ul>
Note: Replace "YOUR ADSENSE CODE" text in the file with your Account ID. Account ID will be found in the top right corner of the Adsense Dashboard. Take a look at the screen shot below for better understanding.  

3. Now, its time to add the CSS part for your widget. Search for the following line in your template.
4. Copy the following code and paste it just above the line mentioned in step3.
.cps {
background:none repeat scroll 0 0 #ddd;
border-top:3px solid #000;
#end {
background:none repeat scroll 0 0 #f9f9f9;
border-bottom:3px solid #000;
border-top:3px solid #000;
margin:0 0 40px;
padding:14px 0 12px 25px;
.actions {
margin:0 20px 0 0;
.tips {
#end ul.tips li {
background:url() no-repeat scroll 0 3px transparent;
margin:0 0 9px;
a.digg {
background:url("http://4.bp.blogspot.com/_Zt-MFCckzsc/Sq981K22-FI/AAAAAAAACNA/qP54J_2HcMQ/s400/digg-1.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
#end ul.actions li {
background:none repeat scroll 0 0 transparent;
margin:0 0 9px;
#end ul li {
#end ul {
a.delicious {
background:url("http://3.bp.blogspot.com/_Zt-MFCckzsc/Sq98mokfzuI/AAAAAAAACM4/_L_0wKNZ2TE/s400/delicious-1.png") no-repeat scroll 0 2px transparent;
padding:2px 0 2px 20px;
a.subscribemini {
background:url("http://2.bp.blogspot.com/_Zt-MFCckzsc/Sq98T8eFqGI/AAAAAAAACMw/1gwnE8qOoIQ/s400/feed.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
a.comment {
background:url("http://2.bp.blogspot.com/_Zt-MFCckzsc/Sq97-VIfenI/AAAAAAAACMo/3IkSWN0C0OU/s400/comment.gif") no-repeat scroll 0 0 transparent;
a.stumble {
background:url("http://2.bp.blogspot.com/_Zt-MFCckzsc/Sq97vV2vdYI/AAAAAAAACMg/phL4ZUZgwPA/s400/stumble.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
a.twit {
background:url("http://1.bp.blogspot.com/_Zt-MFCckzsc/SyPT-xa8c5I/AAAAAAAACtQ/UOzJVxUlFTQ/s400/twitter_16.png") no-repeat scroll 0 0 transparent;
#end h3 {
.hidden {
Note: If you wish to change the background or the border color, then change the codes highlighted in green. For any other customization regarding this widget, leave your comments below and I will try to customize them as you wish.
5. Now, its time to add the javascript part for your widget. To add the script, search for the following line on your blogger template.
Now, paste the following piece of code just above the line mentioned in step 5.
<script type='text/javascript'>
var relatedTitles = new Array();
var relatedTitlesNum = 0;
var relatedUrls = new Array();
function related_results_labels(json) {
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
relatedTitles[relatedTitlesNum] = entry.title.$t;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
relatedUrls[relatedTitlesNum] = entry.link[k].href;
function removeRelatedDuplicates() {
var tmp = new Array(0);
var tmp2 = new Array(0);
for(var i = 0; i < relatedUrls.length; i++) {
if(!contains(tmp, relatedUrls[i])) {
tmp.length += 1;
tmp[tmp.length - 1] = relatedUrls[i];
tmp2.length += 1;
tmp2[tmp2.length - 1] = relatedTitles[i];
relatedTitles = tmp2;
relatedUrls = tmp;
function contains(a, e) {
for(var j = 0; j < a.length; j++) if (a[j]==e) return true;
return false;
function printRelatedLabels() {
var r = Math.floor((relatedTitles.length - 1) * Math.random());
var i = 0;
while (i < relatedTitles.length && i < 20) {
document.write('<li><a href="' + relatedUrls[r] + '">' + relatedTitles[r] + '</a></li>');
if (r < relatedTitles.length - 1) {
} else {
r = 0;
6. That's it!!! Save your template. View the widget on your post pages.

Note: You need to view the post pages to view the widget. That is, click on any of the posts in your blog to view the final result. You cannot find them on the home page of your blog.

I hope you enjoyed this post and the widget as well!!! Please share your views about the widget via comments!!! We love to here from you. More over, you gain backlinks for your comments :)

1 comment:

  1. Hi,Nice post.Thanks for explaining the coding and step by step process about blogs..I need more information from you..


I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary

Such Comments will be removed immediately.