Add Related Posts Widget in Blogger / Blogspot Blogs

By -

Related posts widget appear just below your blogger posts and allow your visitors to navigate through similar posts from your blog. This is also a method to get more page views and keep your visitor on your site for a longer period of time. Remember that this plugin shows the related posts only, it uses some simple algorithm to pull out similar posts from your blog. If you are comfortable with HTML editing, you can add any attractive style to the related posts plugin by editing the CSS code. So, this blogger hack is loaded with performance and style.

How to install Related Posts Blogger Widget To Your Blogspot Blog :

We can add related posts plugin to your blogger blog in two methods. Let me guide you with those two methods one by one. But remember to take a backup of your existing template before editing and adding related posts widget. (How to take online backup of Blogger blogs?)

First Method :

  1. Log in to your blogger Dashboard.
  2. Navigate to your blog’s Layout >> Edit HTML
  3. Expand your widget by clicking on Expand widget templates
  4. Find the following code in your template. (Press Ctrl+F to make a search)
  5. <p><data:post.body/></p>
  6. Now paste the following code just below the above code.
  7. <b:if cond=’data:blog.pageType == “item”‘>
    <div class=’similiar’>
    <!– *****************http://blogger.com*****Jan,2007****************** –>
    <!– *****************Related Articles by Labels – Take Two****************** –>

    <!–

    1. Now, users don’t need to change anything to use this widget. just copy and paste, and done!
    2. The current article will also be listed, now it’s no more.
    –>

    <div class=’widget-content’>
    <h3>Related Posts by Categories</h3>
    <div id=’data2007′/><br/>
    <div id=’SolidBlogger’>
    Related Posts Widget by <u><a href=’http://solidblogger.com’>SolidBlogger</a></u>
    </div>
    <script type=’text/javascript’>

    var homeUrl3 = &quot;<data:blog.homepageUrl/>&quot;;
    var maxNumberOfPostsPerLabel = 4;
    var maxNumberOfLabels = 10;

    maxNumberOfPostsPerLabel = 5;
    maxNumberOfLabels = 3;

    function listEntries10(json) {
    var ul = document.createElement(&#39;ul&#39;);
    var maxPosts = (json.feed.entry.length &lt;= maxNumberOfPostsPerLabel) ?
    json.feed.entry.length : maxNumberOfPostsPerLabel;
    for (var i = 0; i &lt; maxPosts; i++) {
    var entry = json.feed.entry[i];
    var alturl;

    for (var k = 0; k &lt; entry.link.length; k++) {
    if (entry.link[k].rel == &#39;alternate&#39;) {
    alturl = entry.link[k].href;
    break;
    }
    }
    var li = document.createElement(&#39;li&#39;);
    var a = document.createElement(&#39;a&#39;);
    a.href = alturl;

    if(a.href!=location.href) {
    var txt = document.createTextNode(entry.title.$t);
    a.appendChild(txt);
    li.appendChild(a);
    ul.appendChild(li);
    }
    }
    for (var l = 0; l &lt; json.feed.link.length; l++) {
    if (json.feed.link[l].rel == &#39;alternate&#39;) {
    var raw = json.feed.link[l].href;
    var label = raw.substr(homeUrl3.length+13);
    var k;
    for (k=0; k&lt;20; k++) label = label.replace(&quot;%20&quot;, &quot; &quot;);
    var txt = document.createTextNode(label);
    var h = document.createElement(&#39;b&#39;);
    h.appendChild(txt);
    var div1 = document.createElement(&#39;div&#39;);
    div1.appendChild(h);
    div1.appendChild(ul);
    document.getElementById(&#39;data2007&#39;).appendChild(div1);
    }
    }
    }
    function search10(query, label) {

    var script = document.createElement(&#39;script&#39;);
    script.setAttribute(&#39;src&#39;, query + &#39;feeds/posts/default/-/&#39;
    + label +
    &#39;?alt=json-in-script&amp;callback=listEntries10&#39;);
    script.setAttribute(&#39;type&#39;, &#39;text/javascript&#39;);
    document.documentElement.firstChild.appendChild(script);
    }

    var labelArray = new Array();
    var numLabel = 0;

    <b:loop values=’data:posts’ var=’post’>
    <b:loop values=’data:post.labels’ var=’label’>
    textLabel = &quot;<data:label.name/>&quot;;

    var test = 0;
    for (var i = 0; i &lt; labelArray.length; i++)
    if (labelArray[i] == textLabel) test = 1;
    if (test == 0) {
    labelArray.push(textLabel);
    var maxLabels = (labelArray.length &lt;= maxNumberOfLabels) ?
    labelArray.length : maxNumberOfLabels;
    if (numLabel &lt; maxLabels) {
    search10(homeUrl3, textLabel);
    numLabel++;
    }
    }
    </b:loop>
    </b:loop>
    </script>
    </div>

    </div>
    </b:if>

  8. Check out the below screenshot for the correct implementation of the code.
  9. related posts blogger

  10. Save your template to see that you have just added the related posts plugin to your blogger blog.
  11. You are done.

Second Method :

Unlike the above manual method, second method allows you to add related posts widget with a single click. Follow the below steps.

  1. Click on the below button.
  2. Select the blog in which you want to install this widget.
  3. Give a proper title to this widget. You may want to name it as “Related Posts“.
  4. Click on Add Widget to get this widget added to your blogger blog’s sidebar.
  5. You can change this widget’s location by placing it just below the blog post‘s widget. Now it will be displayed in Blog post >> Comments >>  Related Posts order.
  6. Now if you want to add this just below the blog post and above  comments, follow the below steps.
  7. Navigate to Layout >> Edit HTML >> Expand Widget Templates and search for the below code.
  8. <div class='post-footer-line post-footer-line-3'/>
    ...
    </div>
  9. Add the following code just below the above code in your template.
  10. <div id='related_posts'/>
  11. Now the whole code should look like the below screenshot :
  12. add related posts widget to blogger

  13. Save your template at this point.
  14. Now again search for </body> tag in your template. You can also scroll down to end of your template, it’s located there.
  15. Add the following codes just above that </body> tag.
  16. <script src='http://www.google.com/jsapi'/>
    <script src='http://brps.appspot.com/brps.js' type='text/javascript'/>
  17. Save your template and you are done.

These are the methods to add Related posts blogger widget on your blogspot blog. You can follow either the first or the second method to get the related posts showing just below your blogger posts.

Also Read : How to Add Google Analytics Code To Your Blogger Blog

Soumya is the admin and founder of Techcular. He loves to discover and learn new things on Internet. You can find him writing on his personal blog few times.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What is 7 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)