New Related Posts Widget for Blogger / Blogspot Below Each Posts


1. Login to Blogger with your ID.
2. Click Template.
3. Click tab Edit HTML > Proceed > Select Expand Widget Templates.
4. Copy & Past Below Code After ]]></b:skin>

<!--Related Posts Scripts and Styles Start-->
<b:if cond='data:blog.pageType == "item"'>
<style type='text/css'>
#related-posts {
float:center;
text-transform:none;
height:100%;
min-height:100%;
padding-top:5px;
padding-left:5px;
margin-top: 20px;
}
#related-posts .widget{
padding-left:6px;
margin-bottom:10px;
}
#related-posts .widget h2, #related-posts h2{
font-size: 17px;
font-weight: normal;
color: black;
font-family: Arial Narrow;
margin-bottom: 0.75em;
padding-top: 0em;
}
#related-posts a{
font-size:16px;
color: #555555;
font-variant:small-caps;
}
#related-posts a:hover{
text-decoration: none;
color: #ffffff;
font-weight: bold;
}
#related-posts ul{
list-style-type:none;
margin:0 0 0px 0;
padding:0px;
text-decoration:none;
text-color:#000000
}
#related-posts ul li{
list-style-type: none;
border-left: 2px solid #1399CF;
border-bottom: 1px dotted #1399CF;
margin-bottom: 3px;
padding-left: 30px;
padding-top:0px;
}

#related-posts ul li:hover{
background-color: #1399CF;
border-left: 2px solid #B3CA3D;
border-bottom: 1px dotted #B3CA3D;
}
</style>
<script type='text/javascript'>
var relatedpoststitle="Related Posts";
</script>
<script src='http://musicrootz-tools.googlecode.com/files/related_posts.js' type='text/javascript'/>
</b:if>
<!--Related Posts Scripts and Styles End-->

5. Then Copy & Past Below Code After <div class='post-footer'>

<!--Related Posts Code Start--> <b:if cond='data:blog.pageType == &quot;item&quot;'> <div id='related-posts'> <b:loop values='data:post.labels' var='label'> <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=6&quot;' type='text/javascript'/></b:if></b:loop> <script type='text/javascript'> var maxresults=5; removeRelatedDuplicates(); printRelatedLabels(&quot;<data:post.url/>&quot;); </script> </div> </b:if> <!--Related Posts Code End-->

6. Click SAVE TEMPLATE buttons, and wait until your template saved. Now check blogger.



ONE ANOTHER STYLE 

Steps for this hack:

  1. Go to Layout >Edit HTML in your Blogger Dashboard.
  2. Back up your existing Template before making any changes!
  3. Make sure to check the "Expand Widget Templates" box.
  4. Search for the </head> tag.
  5. Add the following code just before the </head> tag.


<style>
#related-posts {
float : left;
width : 500px;
margin-top:10px;
margin-left : 0px;
margin-bottom:15px;
margin-bottom:10px;
}
#related-posts .widget {
list-style-type : none;
margin : 5px 0px 5px 0px;
padding : 0px;
}
#related-posts .widget h2, #related-posts h2 {
color : #333333;
font-size : 13px;
font-weight : bold;
margin : 3px 0px 3px 0px;
padding : 0px 0px 0px 0px;
}
#related-posts ul {
border : medium none;
margin : 0px;
padding : 0px;
}
#related-posts ul li {
display : block;
margin : 0px;
padding-top : 0px;
padding-right : 0px;
padding-bottom : 1px;
padding-left : 0px;
margin-bottom : 0px;
line-height : 2em;
}
</style>

<script type='text/javascript'>
//<![CDATA[
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;
relatedTitlesNum  ;
break;
}
}
}
}
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;
document.write('<ul>');
while (i < relatedTitles.length && i < 20) {
document.write('<li><a href="'   relatedUrls[r]   '">'   relatedTitles[r]   '</a></li>');
if (r < relatedTitles.length - 1) {
r  ;
} else {
r = 0;
}
i  ;
}
document.write('</ul>');
}
//]]>
</script>

    6.  Now search for <data:post.body/> In some of the templates this code may look like this
         <div class='post-body>

          or

          <data:post.body/>

    7.  Add the following code just beneath the code you just searched for.


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

  8. Now Save your Template and see your BLOG!

1/Post a Comment/Comments

Please write here your valuable comment.

  1. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    java training in bangalore
    java training in bangalore

    ReplyDelete

Post a Comment

Please write here your valuable comment.

Previous Post Next Post