How To Add Related Posts With Thumbnails in Blogger

How about adding Related Posts below your blog posts? Advantage of adding Related Posts below your blog post is that your readers may find some of your Related Posts interesting and click on the link to read the post, thus your readers stay time on your blog increases and thereby increases your pageviews. So this tutorial will help you to add Related Posts below your blog posts.

Related Posts With Thumbnails in Blogger

Steps Of  Adding Related Posts Below Blog Posts In Blogger:

Step 1. Go To Blogger Dashboard >> Template >>Edit HTML;

Step 2. Check the “Expand widgets template” box;

Step 3. Search CTRL + F for this piece of code: </head>

Step 4. Copy and paste the below code just above </head> Code

<!--Related Posts with thumbnails Scripts by MukeshMali.com and Styles Start-->
#related-posts{float:left;width:auto}
#related-posts h1{background:none;color:#333;font-weight:700;font:24px Trebuchet MS,sans-serif;margin:0;padding:3px}
#related-posts .MM_img{width:161px;height:110px;transition:all 400ms ease-in-out;-webkit-transition:all 400ms ease-in-out;-moz-transition:all 400ms ease-in-out;-o-transition:all 400ms ease-in-out;-ms-transition:all 400ms ease-in-out;padding:3px 5px}
#related-posts .MM_img:hover{opacity:0.5;filter:alpha(opacity=70);-moz-opacity:.7;-khtml-opacity:.7}
#related-posts .play-button{background:url(https://lh4.googleusercontent.com/-Liprsvdg5j4/URvA_sD-sUI/AAAAAAAACpw/WTbEtnP_qjY/h120/MukeshMali.png) no-repeat center;cursor:pointer}
<!--Related Posts with thumbnails Scripts and Styles End-->
<!-- /Start javascript for Related Posts -->
<script type='text/javascript'>
//<![CDATA[
var relatedTitles=new Arrayundefined);var relatedTitlesNum=0;var relatedUrls=new Arrayundefined);var thumburl=new Arrayundefined);function related_results_labels_thumbsundefinedjson){forundefinedvar i=0;i<json.feed.entry.length;i++){var entry=json.feed.entry[i];relatedTitles[relatedTitlesNum]
=entry.title.$t;try{thumburl[relatedTitlesNum]=entry.gform_foot.url}catchundefinederror) {s=entry.content.$t;a=s.indexOfundefined"<img");b=s.indexOfundefined"src=\"",a);c=s.indexOfundefined"\"",b+5);d=s.substrundefinedb+5,c-b-5);ifundefinedundefineda!=-1)&&undefinedb!=-1)&&undefinedc!=-1)&&undefinedd!="")){thumburl[relatedTitlesNum]=d}else thumburl[relatedTitlesNum]='https://lh6.googleusercontent.com/-AWhPkAKPXYE/URvFDRyVrBI/AAAAAAAACqA/gH0lhjnqdGI/h120/MukeshMaliBig.png'} ifundefinedrelatedTitles[relatedTitlesNum].length>35) relatedTitles[relatedTitlesNum]=relatedTitles[relatedTitlesNum]
.substringundefined0,35)+"..."; forundefinedvar k=0;k<entry.link.length;k++){ifundefinedentry.link[k].rel=='alternate') relatedUrls[relatedTitlesNum]=entry.link[k].href;relatedTitlesNum++}}}} function removeRelatedDuplicates_thumbsundefined){var tmp=new Arrayundefined0);var tmp2=new Arrayundefined0);var tmp3=new Arrayundefined0);forundefinedvar i=0;i<relatedUrls.length;i++){ifundefined!contains_thumbsundefinedtmp,relatedUrls[i])){tmp.length+=1;tmp[tmp.length-1]=relatedUrls[i];tmp2.length+=1;tmp3.length+=1;tmp2[tmp2.length-1]=relatedTitles[i];tmp3[tmp3.length-1]=thumburl[i]}}relatedTitles=tmp2;relatedUrls=tmp;thumburl=tmp3}function contains_thumbsundefineda,e){forundefinedvar j=0;j<a.length;j++)ifundefineda[j]==e)return true;return false}function printRelatedLabels_thumbsundefined){forundefinedvar i=0;i<relatedUrls.length;i++){ifundefinedundefinedrelatedUrls[i]==currentposturl)||undefined!undefinedrelatedTitles[i]))){relatedUrls.spliceundefinedi,1);relatedTitles.spliceundefinedi,1);thumburl.spliceundefinedi,1);i--}}var r=Math.floorundefinedundefinedrelatedTitles.length-1)*Math.randomundefined));var i=0;ifundefinedrelatedTitles.length>0)document.writeundefined'<h1>'+relatedpoststitle+'</h1>');
document.writeundefined'<div style="clear: both;"/>');whileundefinedi<relatedTitles.length&&i<20&&i<maxresults){document.writeundefined'<a style="text-decoration:none;margin:0 10px 5px 0;float:left;border:solid 1px #ccc;');ifundefinedi!=0)document.writeundefined'border:solid 1px #ccc;"');else document.writeundefined'"');document.writeundefined' href="'+relatedUrls[r]+'"><div class="play-button"><img class="MM_img" src="'+thumburl[r]+'"/><br/></div><div style="width:160px;padding:0 5px;color:#222;height:40px;text-align:center;margin:0px 0px; font:14px PT Sans Narrow; line-height:16px;">'+relatedTitles[r]+'</div></a>');ifundefinedr<
relatedTitles.length-1){r++}else{r=0}i++}document.writeundefined'</div>');
relatedUrls.spliceundefined0,relatedUrls.length);thumburl.spliceundefined0,thumburl.length);
relatedTitles.spliceundefined0,relatedTitles.length)}
//]]> </script>
<!-- /End javascript for Related Posts -->

Step 5. Now find the following code: post-footer-line post-footer-line-1

Step 6. And just above it, copy and paste the below code:

<!-- Related Posts with Thumbnails 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_thumbs&amp;max-results=8&quot;' type='text/javascript'/></b:if></b:loop>
<script type='text/javascript'>
var currentposturl=&quot;<data:post.url/>&quot;;
var maxresults=4;
var relatedpoststitle=&quot;Related Posts  :&quot;;
removeRelatedDuplicates_thumbsundefined);
printRelatedLabels_thumbsundefined);
</script>
</div><div style='clear:both'/>
</b:if>
<!-- Related Posts with Thumbnails Code End-->

See the Demo of Related Post with Thumbnail in Blogger

Step 7. Save the Template

Enjoy :)

About Mukesh Mali

Mukesh Mali is a 25 years old Full-Time Blogger from Rajasthan, India. He is a freelance writer on topics related to Website Optimization (SEO), Blogging, HTML, CSS & Photoshop.

Like this Article ? Subscribe to Our Feeds

This Site Runs on the Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!

Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website/blog

Comments

  1. Hey ,
    This Widget is Very Cool !! I Will be Trying it on my Blog ! Thanks for Sharing !!
    Srikanth recently posted…Lava Unveils ETab Xtron 7-inch Tablet at Rs.6,499My Profile

  2. Hi I have tried with this code more than 1 hour but not working….Can you send me the code from your Demo. I want to add like your demo…Plz reply me soon…..

  3. finally found this helpful tips..thanks for giving this, i spend time for searching this realated postThanks.

    Bloggerheroe.Com recently posted…9 WordPress Anti Spam PluginMy Profile

  4. Hi Bro, have you got my templates??? Is it working?
    Rabbi recently posted…Add Elegant Colored Author Box At The Bottom Of Every Blog PostsMy Profile

  5. Nice tips, i hope it’s work
    PutraTech recently posted…Galaxy Star & Pocket Neo, Cheap Smartphone from SamsungMy Profile

  6. Nice post pro, but all the post I had seen are related to this but not working,pls help.
    Adesanmi adedotun recently posted…How to achieve the effect of flipping 3D eBook in 3D space.My Profile

Our Comment Policy: We're glad that you chose to leave a comment. If you don't leave your REAL name in the name field, I will trash your comment even without reading it (so no matter how great it is). Look below the comment form for info on adding keywords in the name field. Please keep in mind that all comments are moderated according to our comment policy, and all links are dofollow. Let's have a meaningful conversation.

Leave a Comment

*

CommentLuv badge