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’>
    <!– **********************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=’’>SolidBlogger</a></u>
    <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;; k++) {
    if ([k].rel == &#39;alternate&#39;) {
    alturl =[k].href;
    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);
    for (var l = 0; l &lt;; l++) {
    if ([l].rel == &#39;alternate&#39;) {
    var raw =[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;);
    var div1 = document.createElement(&#39;div&#39;);
    function search10(query, label) {

    var script = document.createElement(&#39;script&#39;);
    script.setAttribute(&#39;src&#39;, query + &#39;feeds/posts/default/-/&#39;
    + label +
    script.setAttribute(&#39;type&#39;, &#39;text/javascript&#39;);

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

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

    var test = 0;
    for (var i = 0; i &lt; labelArray.length; i++)
    if (labelArray[i] == textLabel) test = 1;
    if (test == 0) {
    var maxLabels = (labelArray.length &lt;= maxNumberOfLabels) ?
    labelArray.length : maxNumberOfLabels;
    if (numLabel &lt; maxLabels) {
    search10(homeUrl3, textLabel);


  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'/>
  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=''/>
    <script src='' 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.

40 Comments to Add Related Posts Widget in Blogger / Blogspot Blogs

  1. Thank you for this widget. However, is there a way that we can limit the number of related posts to only a certain number (e.g. Five). The thing is, if you have many related labels on your post, it takes to long to load.

  2. @ Ian : Yes, you can configure no of related post. Simply edit the following code in your template with your values and you are done.

    <blackquote>maxNumberOfPostsPerLabel = 100;

    maxNumberOfLabels = 3;

    NOTE : Earlier code in this post was showing 100 related posts 😛 It's edited now to show 5 posts from each label and 3 labels maximum.

  3. i am getting this error

    Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.

    XML error message: Open quote is expected for attribute "{1}" associated with an element type "cond".

  4. Bewyn : I'm not getting you! What you couldn't find? The code is above, simply copy it and paste in your template. That's it. Be specific with your problem, so that I can help you further.

  5. These seemed to be a very good breakdown, but I can't seem to get it working. Is there anyway that I could get some help? It is saying that the code is incorrect

  6. hi,

    i have successfully added the widget on my website (; but when I tried to put it on my other blog (, using method #2, I encounter a little problem.

    I couldn't find the

    ; because I only have .

    I already paste it below as ur instruction, but doesn't seem to work .. I tried to change the <p class to <div class (I don't know what it means), but didn't work also.

    Any advice? Anyway I tried using your #1 method but didn't work also .. :(

    Heeeeeeeellppp !! :)

    Thank you so much :)

  7. Paisa Vasool

    Thanks a lot this really helped me. I initially had linkedwithin and it was making the pages look a little off. Now with this it looks nice and neat.

  8. hii solidblogger,

    thanks for this nice blog I really appreciate your great work .

    The new issue about this "related post widget,

    the programmer start blocking all blogs, that have illegal content,

    The author of BRPS may be blocking your blogs from

    * Copyright infringement (If your blogs have links to any illegal downloads, directly or indirectly, upload by youself or not, please DO NOT use BRPS. Otherwise, your blogs will be BLOCKED for sure),

    * Hate against a protected group,

    * Adult or pornographic images,

    * Promotion of dangerous and illegal activity,

    * Content facilitating phishing or account hijacking,

    * Impersonated user identity, or

    * Abuse this service.

    and it will appear this message instead of showing related posts

    Related Posts :

    This blog is blocked from using Blogger Related Posts Service. If you are the blog owner and believe this blocking is a mistake, please contact the author of BRPS.

  9. Is there a way to specify the post by name you want displayed? Example: I only want posts with the word 'Giveaways' to display in the sidebar?

  10. @ Danielle : I don't think there is any such service to filter words and show the resulting posts. You may add a specific label (such as : Giveaway) to such posts and then display the posts under that label in the sidebar.

  11. This code does not work for me..

    I'm getting this error message..

    Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.

    XML error message: Open quote is expected for attribute "{1}" associated with an element type "cond".

    I followed the 1st method..

    Do this error because i already add read more code to my blog?

    Please help me?

  12. @ Jatt : You could have done something wrong during implementation as it has noting to do with the "read more" hack. Send me your template so that I can look into that. Use "Contact Us" form.

  13. thanks a lot, i was having problem locating the first method.
    i mean i don't think there is this code in my template
    < data. post:body….
    in my template…
    where can i locate it.. should in case i want to use the code some time.
    thanks again.

  14. I tried the first method. It worked great. Just I would like to place the related posts on the right side bar. How would I do that?

  15. I followed method #2 and this message appears below my blog posts:

    Could not find the possible script tags, you can only include BRPS client brps.js script once.

    Can you help me out? Thanks!


    PS–I tried method 1 but got the error message commented on above–"Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.

    XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”."

  16. The “Related Posts” titled showed up, but nothing else did. No related posts links at all. I used method number two.

    I wonder if this widget is compatible with Josh Peterson’s “Simple” Blogger template.



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=""> <s> <strike> <strong>

What is 11 + 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) :-)