Make thumbnail for related posts

You may know the code for related posts which I showed in previous post in Simplex Design blog. In this post ,I want to show you the code for adding thumbnail to related posts . This code is based on related posts code before but add some lines for thumbnail . I myself don't create this code ,I found it in Bloggerpluggins blog,and introduce it here ,I hope it helpful for you all .

You can take a look on related post with thumbnails at live demo
 


Here is steps for doing this hack :
1,Go to Dashboard ,continue to Layout --> Edit HTML .Checked on Expand Widgets template .
2,Look for  </head>
and replace it with :

<!--Related Posts with thumbnails Scripts and Styles Start-->
<!-- remove --><b:if cond='data:blog.pageType == &quot;item&quot;'>
<style type="text/css">
#related-posts {
float:center;
text-transform:none;
height:100%;
min-height:100%;
padding-top:5px;
padding-left:5px;
}

#related-posts h2{
font-size: 1.6em;
font-weight: bold;
color: black;
font-family: Georgia, &#8220;Times New Roman&#8221;, Times, serif;
margin-bottom: 0.75em;
margin-top: 0em;
padding-top: 0em;
}
#related-posts a{
color:black;
}
#related-posts a:hover{
color:black;
}

#related-posts  a:hover {
background-color:#d4eaf2;
}
</style>
<script type='text/javascript'>
var defaultnoimage="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB4KkVU5-mKm8JQlPqgLaNv4UPE-HjIRbENzKojQw_RHoFB-RjMWYfR2pMadRANqxziPGOySKxBJ2H7CtujLZI8pWEQkZIcNVr8caOxgIArYtu5vAf1xLB_5KZ3eWcEJ72Ch2UpRW8jg8/s400/noimage.png";
var maxresults=5;
var splittercolor="#d4eaf2";
var relatedpoststitle="Related Posts";
</script>
<script src='http://blogergadgets.googlecode.com/files/related-posts-with-thumbnails-for-blogger-pro.js' type='text/javascript'/>
<!-- remove --></b:if>
<!--Related Posts with thumbnails Scripts and Styles End-->
</head>
This is CSS for formatting related posts section .
3,Find <div class='post-footer-line post-footer-line-1'>
or <p class='post-footer-line post-footer-line-1'>
if you don't find any of two lines above in templates ( for example ,in template I designed ^^) you can find this <p><data:post.body/></p>
and add the code below after these line :
<!-- Related Posts with Thumbnails Code Start-->
<!-- remove --><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>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels_thumbs&amp;max-results=6&quot;' type='text/javascript'/></b:loop>
<script type='text/javascript'>
removeRelatedDuplicates_thumbs();
printRelatedLabels_thumbs(&quot;<data:post.url/>&quot;);
</script>
</div><div style='clear:both'/>
<!-- remove --></b:if>
<!-- Related Posts with Thumbnails Code End-->
There are some variables in this code and you can change its value for making related posts section as you want .

var maxresults=5;
the number of related post which will be show

var relatedpoststitle="Related Posts";
title of related posts section
var defaultnoimage="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB4KkVU5-mKm8JQlPqgLaNv4UPE-HjIRbENzKojQw_RHoFB-RjMWYfR2pMadRANqxziPGOySKxBJ2H7CtujLZI8pWEQkZIcNVr8caOxgIArYtu5vAf1xLB_5KZ3eWcEJ72Ch2UpRW8jg8/s400/noimage.png";
url of default image if it can't create thumbnail

var splittercolor="#d4eaf2";
color of splitter line .
4,Save your template and you are done .

huy signature

Share this post

Advertisement

0 comments:

Post a Comment