Tuesday, 22 April 2014

Related Post Widget for Blogger

Related Post Widget for Blogger
Today I am Going To show You to add a RELATED POST WIDGET in your Blogger Blog , So that, Visitors may spend alonger time at your site :)
So lets get started

 1. Goto Blogger Dashboard  > Template > Edit HTML
 2. Search for the following peice of code

</head>


3. Add the code just above </head>


<!--Related Posts with thumbnails Scripts and Styles By askdanyal.com starts-->
<!-- remove --><b:if cond='data:blog.pageType == &quot;item&quot;'><style type='text/css'>
#related-posts{float:left;width:auto;}
#related-posts a{border-right: 1px dotted #eaeaea;}
#related-posts a:hover{background: #f2f2f2;}
#related-posts h2{margin-top: 10px;background:none;font:18px Oswald;padding:3px;color:#999999; text-transform:uppercase;}
#related-posts .related_img {margin:5px;border:4px solid #f2f2f2;width:100px;height:100px;transition:all 300ms ease-in-out;-webkit-transition:all 300ms ease-in-out;-moz-transition:all 300ms ease-in-out;-o-transition:all 300ms ease-in-out;-ms-transition:all 300ms ease-in-out;}
#related-title {color:#222;text-align:center;padding: 0 10px;font-size:14px Oswald; line-height:16px;text-shadow:0 2px 2px #fff;height:28px;width:100px;}
#related-posts .related_img:hover{border:4px solid #E8E8E8;opacity:.7;filter:alpha(opacity=70);-moz-opacity:.7;-khtml-opacity:.7}</style>
<script type='text/javascript' src='http://helplogger.googlecode.com/svn/trunk/relatedposts.js' />
<!-- remove --></b:if>
<!--Related Posts with thumbnails Scripts and Styles By askdanyal.com End-->

4. Now Find

<div class='post-footer'> (if this appears twice , select the 2nd one)


5. Paste the following code above it

<!-- 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=5&quot;' type='text/javascript'/></b:if></b:loop>
<script type='text/javascript'>
var currentposturl=&quot;<data:post.url/>&quot;;
var maxresults=5;
var relatedpoststitle=&quot;<b>Related Posts:</b>&quot;;
removeRelatedDuplicates_thumbs();
printRelatedLabels_thumbs();
</script>
</div><div class='clear'/>
</b:if><b:if cond='data:blog.url == data:blog.homepageUrl'><b:if cond='data:post.isFirstPost'>
</b:if></b:if><!-- Related Posts with Thumbnails Code End-->


Save the template and You are done :)

CUSTOMISATION:

Here are some easy tips to customise the widget :)


  • if you want to change the width and height of thumbnails, change the value in red (100px) in step 3
  • if you want change the color and size of related posts titles, change the value in orange in step 3
  • remove the line in green if you want the related posts to be displayed in homepage too  in step 3 and  remove the lines in green In the last step
  • if you want to change the number of posts displayed change the value from max-results=5  in the last step
Share this article
author

This Post Was Written By : Danyal

Danyal , A simple dude from Pakistan , Loves to help others , Blogs as a hobby and Always looking to help people. This Blog is also dedicated to all those who are looking for answers.

Get Free Email Updates to your Inbox!

0 comments:

Post a Comment

 
Copyright © 2014 AskDanyal - All About Internet • All Rights Reserved.
back to top