Saturday, October 3, 2009

Show Related Posts in Blogger

Its very easy to get Related Posts in WordPress but now getting Related Posts Widget in Blogger is also too easy. Many people have Asked Me About how to Add this Related Post plugin for Blogger just like I have done. After reading, to admin's comment in this post I've decided to post it here. Just check it out!

Just follow the instructions below to add "Related Post" widget in Blogger.
Step 1
Go to Layout => Edit HTML in your blog


Please Note: Before Editing your Template, Save a copy of your current template by clicking 'Download Full Template' in 'Edit HTML' page of the Blogger 'Layout' Window and 'Preview' the changes before Saving
Add code below just above </head> tag, you can search it by pressing Ctrl + F



<style>

#related-posts {
float : left;
width : 540px;
margin-top:20px;
margin-left : 5px;
margin-bottom:20px;
font : 11px Verdana;
margin-bottom:10px;
}
#related-posts .widget {
list-style-type : none;
margin : 5px 0 5px 0;
padding : 0;
}
#related-posts .widget h2, #related-posts h2 {
color : #940f04;
font-size : 20px;
font-weight : normal;
margin : 5px 7px 0;
padding : 0 0 5px;
}
#related-posts a {
color : #054474;
font-size : 11px;
text-decoration : none;
}
#related-posts a:hover {
color : #054474;
text-decoration : none;
}
#related-posts ul {
border : medium none;
margin : 10px;
padding : 0;
}
#related-posts ul li {
display : block;
background : url(&quot;http://i548.photobucket.com/albums/ii355/gohitech/newconcept_bullet.png&quot;) no-repeat 0 0;
margin : 0;
padding-top : 0;
padding-right : 0;
padding-bottom : 1px;
padding-left : 16px;
margin-bottom : 5px;
line-height : 2em;
border-bottom:1px dotted #cccccc;
}

</style>

<script src='http://gohitech.googlecode.com/files/Post.js' type='text/javascript'/>

Now save your Template.

Step 2
Now look for <p><data:post.body/></p> in the template. Make sure to "Expand Widget Template" in the Edit HTML page.
Add following code below <p><data:post.body/></p>

<b:if cond='data:blog.pageType == "item"'>
<div id="related-posts">
<h2>Other Recommended Posts on <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> </h2>

<script type='text/javascript'> removeRelatedDuplicates(); printRelatedLabels(); </script>

</div></b:if>

Save your template and you are done with two step installation of code.

If you have any problem please use comments form below.

No comments:

Post a Comment