Related Posts Widget for Blogger v1

The related posts widget will show a new related posts section below your post.The related posts widget fetches the related posts from those posts having the same label as the current post.

To implement the related posts widget you will have to follow 2 simple replacement steps.

1.Login to your blogger account and get into your Dashboard

2.From there go to Layout > Edit HTML and expand your widget templates(option on the right)

3.Now find this line of code

</head>

and replace it with

<!--Related Posts Scripts and Styles Start-->
<!--Remove--><b:if cond='data:blog.pageType == "item"'>
<style type="text/css">
#related-posts {
float:center;
text-transform:none;
height:100%;
min-height:100%;
padding-top:5px;
padding-left:5px;
}
#related-posts .widget{
padding-left:6px;
margin-bottom:10px;
}
#related-posts .widget h2, #related-posts h2{
font-size: 1.6em;
font-weight: bold;
color: black;
font-family: Georgia, “Times New Roman”, Times, serif;
margin-bottom: 0.75em;
margin-top: 0em;
padding-top: 0em;
}
#related-posts a{
color:blue;
}
#related-posts a:hover{
color:blue;
}
#related-posts ul{
list-style-type:none;
margin:0 0 0px 0;
padding:0px;
text-decoration:bold;
font-size:15px;
text-color:#000000
}
#related-posts ul li{
background:transparent url(/_u4gySN2ZgqE/snzhv_c6bti/greentickbullet.png) no-repeat ;
display:block;
list-style-type:none;
margin-bottom: 13px;
padding-left: 30px;
padding-top:0px;}
</style>
<script type='text/javascript'>
var relatedpoststitle="Related Posts";
</script>
<script src='...' type='text/javascript'/>
<!--Remove--></b:if>
<!--Related Posts Scripts and Styles End-->
</head>

If you want to change the title of your widget you can edit this line of the above code

var relatedpoststitle="Related Posts";
If you want you can edit the blue and black colors present in this code

4.Now find this line of code

<div class='post-footer-line post-footer-line-1'>

If you cant find it then try finding this one

<p class='post-footer-line post-footer-line-1'>

Now immediately after any of these lines(whichever you could find) place this code snippet

<!-- Related Posts Code Start-->
<!--Remove--><b:if cond='data:blog.pageType == "item"'>
<div id='related-posts'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast != "true"'>
</b:if>
<b:if cond='data:blog.pageType == "item"'>
<script expr:src='"/feeds/posts/summary/-/" + data:label.name + "?alt=json-in-script&callback=related_results_labels&max-results=6"' type='text/javascript'/></b:if></b:loop><a href='related-posts-for-blogger-widget.html'><img style="border: 0" alt="Related Posts Widget for Blogger" src="..." /></a>
<script type='text/javascript'>
var maxresults=5;
removeRelatedDuplicates(); printRelatedLabels("<data:post.url/>");
</script>
</div>
<!--Remove--></b:if>

the below line of code determines the number of related posts that are displayed and by default 6 posts are fetched from each label.

var maxresults=5;

Now you should have a working related posts widget on your blog.If you want to customize the look and feel,then you can alter the CSS rules.OR if you have any doubts or need any modifications,you can surely contact me via comments or at Blogger Forums .The codes are well commented .So this can be easily removed whenever you want..

Note: If you want to display the Related Posts on every page, then remove the 4 lines of code starting with <!--Remove—>

Update 29/03 : If the script is not working anymore, do change

Sorry for the trouble :-)

327 comments :

  1. appaa

  2. yes this is indeed a better version of this hack

  3. Youth Ki AwaazAugust 3 at 8:55 PM

    Thanks a lot, my blog looks so professional now. Take care and keep us updated!

    Anshul

  4. is there any demo..??

  5. @sam this is my example ;) enjoy

  6. @ipsj ,
    you have added the first part of the code..
    but i dont think you added the second part of the code..
    i dont see any related post code below
    <p class='post-footer-line post-footer-line-1'>

  7. i don't know why my blog do not appears on google search, anyone of you help me on this

  8. hmm...i'll try thnxs bro

  9. hi aneesh! nice article. I did apply your tip to my blog. Windows Technology Blog But I want to reduce the spacing between the posts urls, how can i do that?

  10. in #related-posts ul li

    there is a line
    margin-bottom:somevalue;
    Adjust it so that the gap is set to what you need.

  11. hi aneesh, thanks. I already tried that one, but I couldn't find any difference. Then when I made it to 3px, i could find the difference. thanks for your help!!

  12. Thanks a lot

  13. Beautiful widget!
    let's join us to download ebook free

  14. Hi, Aneesh.

    Thanks a lot for this wonderful widget. It is excellent.

    Also, the other widgets of this blog are quite good too. Specially, I like the way how the readers can customize some of the widgets (Pop-out on clicking on a button)

    Good work again!

    Regards,

    Viral

  15. @Viral
    thanks for the appreciation! :)

  16. Daniel BianchiniAugust 27 at 1:14 AM

    Hi,

    I have added the code to my blog and it hasn't worked. Any ideas?


    Thanks

  17. its working fine on that page that you have mentioned..If you are talking of that No Image thumbnail,it is the default thumbnail which will be displayed if no images are present in that particular related post(no images uploaded via blogger post editor).

  18. hi,
    it didn't work on my blog and i don'know why,could you help me :)

  19. by the way i forgot write my blog url :)

  20. don't work

  21. Kids Are Great!September 4 at 9:39 AM

    Okay, I tried this one instead of the one with thumbnails and it shows links to other posts that don't necessarily relate to the post a visitor is commenting on.

    But, at least it shows something and that's an improvement.

    The only problem I still have with it is that the related links do NOT show up on the main page or the post's page. They only show up if someone clicks to make a comment. Is that how it's supposed to work?

  22. both of the codes have b:if conditions.. these b:if conditions were added to prevent the related posts from being shown on the main pages..

    if you remove the b:if conditions from both the code snippets,then the related posts will appear on every page..

    b:if conditions look like
    <b:if cond='data:blog.pageType == "item"'>
    and
    </b:if>

  23. thanks good wisget :)

  24. How come images don't appear in my related posts? Thanks!

  25. Much better than the one from LinkWithin!!

  26. Hye.. i already install this code on my blog.. This related post actually work on my previous post.. But, when i install disqus comment box on my blog, the related post never showed again.. Whats is the problem actually ? can u help me ?

    Regards,
    Zaarz

  27. @ZaaRz did you upload the template to disqus for inseting the comment form.. if thats the case they might have removed some codes.. Try adding it again.. By the way i see the related posts with thumbnails working on your blog now..

  28. Chichi {From Now Till I Do}September 24 at 12:00 AM

    I have followed the instructions but it doesn't seem to work for me, any ideas?

  29. Hi,

    I tried this but it wont work on my blog

    I have this error: TEMPLATE ERROR: No dictionary named: 'post' in: ['blog']

    Any ideas? please help

  30. @Me ,
    i don't see the codes on your blog..
    @mogo cafe ,
    now its working fine on your blog.

  31. Thank you very much! I have been looking for this feature in an easy to use format for Blogger and this is it.

  32. I added the hack and it did not work...

    I am puzzled. Grateful for any help




    Thanks

  33. Thank you

  34. Awesome. Thanks!

  35. Hi Aneesh!

    I cannot seem to find any of the footer lines. Any alternatives for my problem?

    Thanks!

  36. it's work, but i have one problem... it's closed by post label, time, and disqus.. please help me solving this problem

  37. hi... i try this but i stop in this 4.Now find this line of code
    i did not find any code like this

    help please

  38. Thank you very much. Those codes works just fine for my blog. If you don't mind, I'd like to ask you to review it too. Since I'm new to blogger's things.
    Based on Minima template.

  39. How can I change the font in those related post?

  40. @irwanwr ,
    you can add your own font styles to the CSS

  41. thankz

  42. thank you verry much.

  43. Hi, I love this and it's working fine on my blog! Can you tell me how to change the bullets for each related post from that green arrow to something more like you have on this site?

    Thanks!

  44. One more question...

    I can't seem to figure out how to increase the space between the bottom of the related posts and the top of my labels? I would like a little more space there.

    Thanks for your reply!

  45. @Rebecca
    you can change the bullet image by changing with the url of your bullet image..

    You can add spacing
    just below #related-posts {
    add,
    margin-bottom:10px;

  46. Aneesh,

    Those adjustments were SO easy and worked like a charm!

    Much appreciated.

    Rebecca :-)

  47. bagus friend tips-nya

  48. Great Job.

  49. how to place this widget (Related Posts) belom the Adsense Code located between posting? this original code always place Related Posts above the Adsense. i need it to place Related post below Adsense. please refer to my blog

  50. try placing the code from step 4 just above <div class='blog-pager' id='blog-pager'>

  51. Hi,

    Installed the code on my blog. I see the related posts immediately after publishing then they disappear. Can't figure out what I'm doing wrong. If you could take a look, I would appreciate it.

    Thanks.

  52. Dating For Today's ManNovember 29 at 2:56 AM

    Thank you very much for the code. It works perfectly in my blog!

  53. G'day, firstly thanks for the widget, secondly, how does a non technically minded person change the font of the 'related posts' links? My site is all in Georgia, can I change the font?

  54. Working perfectly on posts but not showing in homepage andy help?

  55. Wow, great! I'll try!

  56. Kothapally ArunDecember 14 at 9:30 AM

    Thanks a lot.
    Well explained tutorial

  57. Thanks, worked like a charm.

  58. Thank you so much, check out what it looks like now!

    Once question, why does it not say "Related Posts" on all of my posts?

  59. hello Aneesh
    how can i change the blackground color to black?

  60. Hi!
    It's not working for me, any ideas?

    Thanks

  61. so many way to hack the code and i really confuse where is the best from all. I think wordpress is easier than blogspot but somehow blogspot is more freely to use that wordpress.

  62. Works like magic... I've been looking for this since last year... I edited the css and removed the tiny image and it looks wonderful. I'm using it on my blog already. Thanks a lot. God bless.

  63. Hi, how to place this related posts at the bottom of my post and not on top? thanks.

  64. I tried to apply but it can't. Is there any to add as HTML/JavaScript widget

  65. cool. tks a lot

  66. Thanks, a lot . Tried many of similar posts hacks but this one worked on my blog

  67. I hope I followed your steps, but doesn't seems to work. Could you please help me.

  68. @Priya its working now :)

  69. i couldn't find the second line. Please do help me. Thank u:)

  70. It works but why the title "related posts" doesn't show up. Is it related with the code var relatedpoststitle="Related Posts"; that automatically changes into var relatedpoststitle="Related Posts";. How to fix it?

  71. @Shalini Subramaniam - Then try placing it after <data:post.body/>

  72. hiya! this doesn't work with me, i've followed all the steps. and when i want it to start fresh it doesn't go back to the original template, any idea what's going on?

  73. zam said...
    It works but why the title "related posts" doesn't show up. Is it related with the code var relatedpoststitle="Related Posts"; that automatically changes into var relatedpoststitle="Related Posts";. How to fix it?

    Same problem as Zam...any solutions?

  74. White Laptop Computers InfoFebruary 11 at 1:29 PM

    My Problem same with Zam and Booty Bandit.. How to fix it ?

  75. @All - Can you show me the url.. I am using the same code here on this site. with a little different styling..

  76. hi ...
    if i want the related post to show "posts that have the same titel"

    ex: 1. ligion review 2. ligion preview 3. ligion Mp3 4. ligion "in make".

    so if the post is about ligion mp3.
    can the related post show, the other 3 posts as releated post?

  77. @Bollytadka - nope realted posts are based on labels. If all of those posts have the same label, then they may come up.

  78. thx aneesh

  79. thank

  80. i have included the parts of code in my website but it still don't work :(


    anybody can help me to fix it right?

  81. HimaBindu VejellaFebruary 16 at 1:02 PM

    Thanks for the info. It worked.

  82. Seems like 20 is the maximum amount for related posts. Is there anyway to increase that amount? Also is it possible to arrange the related posts in chronological order? I want the newest ones to be on top.

  83. nothing happen??

  84. Thank you :) I tryied some widget's like this too, but they aren't work.
    Your widget's really work. You are great :)

  85. What if I can't find the second part of the code?

    I use someone's template, and there is no
    class='post-footer-line post-footer-line-1
    or
    p class='post-footer-line post-footer-line-1

    Thanks

  86. hi!

    can you please check why it's not working, i will be so greatful.

  87. can you please help me.... I have successfully save the template but it seems nothings happens. please check my site...

  88. pls check myu blog. its not working'

  89. Fantastic widget, thanks so much!

  90. I also faced the same problems

  91. Okay,I want the related posts to show on every post on every page. I followed the instructions in the above post. Took out all the b:if conditions from both code snippets, got div needs to be closed. added /div, still did not work. Took out just part of b:if and get loop needs same termination.

    Can you please advise me as to what lines I should exactly remove to have this occur on each page? Thank you. I like the way it looks on opening a post.

  92. i use custom domain with blogger i tried this code it just dont work any idea

  93. It's quite complicated to do it, but great tips... thanks

  94. Hi,

    I tried this but it wont work on my blog

    I have this error: TEMPLATE ERROR: No dictionary named: 'post' in: ['blog']

    Any ideas? please help

  95. hi
    I tried this but it wont work on my blog

  96. @photoshopya - related posts are based on labels. So you need to label your posts. and it would be better if you use the "related posts with thumbnails widget". (as you have images in your blog posts)

  97. Its doesn't work on my blog.
    :(

  98. @Caroline Ng May Lin - you have added the code twice(one is slightly different though) to your blog. Remove both of them and re add :)

  99. i did it, still not working on page.

  100. @Caroline - thats because each of your labels have a single post only. Related Posts = Posts under the same label.

  101. Hi,

    I have this error: TEMPLATE ERROR: No dictionary named: 'post' in: ['blog']



    Any ideas? please help

    Derk Zijlker

  102. @derkzijlker - add the big code of step 4 below <data:post.body/>

    Btw you already own a domain name. you can move your blog to some sub-domain like if you want :) . You will find the instructions for the same on this blog :)

  103. I try to my blog.But I don't look change and can't see related post.Why...what happend?

  104. doublerainbow69April 3 at 12:34 PM

    i dont know why i get ths 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: The element type "html" must be terminated by the matching end-tag "".

    im using a custom template, if that matters.

  105. thank for information. It's nice :)

  106. Hi Aneesh, thnx for your help. But I still don't know how to fix the problem.

    TEMPLATE ERROR: No dictionary named: 'post' in: ['blog']

    Can't find in my template.

    Can you help me fix this error?

    THANKS

    Derk Zijlker

  107. Instead Of "Related Posts" I want it to appear as "You Might Also Like" how do I change this text ?

    Thanks a Lot for all the help and Tips :)

  108. @Sagar - you will find the answer in Step 3 :)

  109. @Sagar, also check out here.

  110. all codes are working fine
    but i am getting a problem that title "Related posts" is not appearing at my site
    here is demo
    plz help me

  111. thank you very much dear i have made it as your instructions.
    here you may see it.
    again thanks.
    it gives professional look to my blog.

  112. Blog La Pequeña GreciaApril 18 at 6:28 PM

    Thanks a lot from Venezuela. This widget works perfectly!!
    Nice day for you. Very exciting widget...

  113. Engineering360April 18 at 10:37 PM

    Thanks for this nice widget...

    I have completely removed the bullets and change text color, size and face. Now it's looking really Excellent. Please see my blog here

  114. Oh well, this one didn't work as well, as I'm no good with CSS, or CCS? heh

    Is it hard to make a widget that "catches" the look of one's blog? Like, identifying colors and fonts?

    Hmm. Seems rather complicated. But thanks anyway for sharing this. :)

  115. thanks for very nice widget .

  116. Thanks a lot

    I complate my blog:

  117. Everything seems to be working except the images do not show in the related posts. I am new to Blogger so maybe I have overlooked something. I was also wondering if there was a way to assign an image to a post, without having to place in right in my post. Meaning I would like to see the image on the related posts but not in the middle of the post once I go to it.

    If you have a chance could you check this out? Thanks.

  118. nice! i'm currently using it now. thanks :)

  119. Hey Nice Post! I will be working on this in my Blog, ASAP!

    Tell me what you feel! :)

  120. Thanks, this is so easy and it worked perfectly when I first put it in. But I changed templates and added this again, it just shows the title but not the images. Help please.

  121. Never mind, I just found your other post, :). Thanks!

  122. TheDeppest__InkMay 21 at 4:33 PM

    Hi again since Blogger error BX -...

    I followed all the steps and I'm wondering what goes wrong. Read all comments but I am more confused that in the begging

    I'd really solve the problem because I'm really interested to have a "realted post" widget

  123. TheDeppest__InkMay 21 at 4:33 PM

    Forgot to mention my blog:)

  124. TheDeppest__InkMay 22 at 1:45 AM

    It works! I can erase the old comments, so feel free to delete them.
    I'm soo happy now!

  125. wont work on my blog

  126. Not working in my Blog

    Help!

  127. Hey,
    the Related Posts title does not show when there is only one related post. How do you fix this?

  128. Why doesn't the title show up when there is only one related post?

  129. :(
    The element type "html" must be terminated by the matching end-tag "".

  130. I followed all the steps and I'm wondering what goes wrong.
    my related post became wierd..

    please advice..

  131. i need help its not working

  132. shabari nathJune 10 at 8:46 PM

    hey plzz help me its not working for my blog

  133. hello, Aneesh

    I love your hacks and I used the one with the page counter. this one doesn't work cause I can't find the second line of html code in step 4.

    please help me

    hugz

  134. oops, I forgot this:

  135. hi annie,
    try finding <data:post.body/> instead. and paste the code below it.

  136. Hey :)

    I put this widget on my blog but I don´t want it to be in this light blue thing under the posts. How can I change that?

    Greetings,
    Carry

  137. i have used the widget but having no thumbnail !
    can i have ur help?

  138. Waleed AhsanJune 26 at 2:36 PM

    u R d best
    ItS woRkiNg...

  139. great work.thanks dude..
    working for me.

  140. Nilesh PanchalJuly 5 at 9:32 PM

    Hi,

    Its shown on my site now :)

    thanks

  141. riddlemaniacJuly 6 at 7:23 PM

    it works inside my post..how about displaying it on the image..i removed the line starting with and i could see only 4 thumbnails instead of 6..please help

  142. Great post!!

    I have a question. I have successfully used this on my blog but is there a way to display this widget below the read more "jump links" on the index and archive pages? I couldn't figure out how to do this.

    I copied the code and pasted it underneath the jump link code and tried using "archive" and "index" in the if condition for data:blog.pageType but it doesn't display anything.

    Any suggestion will be greatly appreciated.

  143. This is a cool Realated post widget....
    Now my blog look stylish after adding it.....

  144. How do you put a border around it!

  145. honest realtor moscowJuly 15 at 3:03 PM

    It was helpful. Thank a lot =)
    It looks better now =)
    I am so happy =)))

  146. speak_englishJuly 16 at 11:49 PM

    super, thanks a lot, I was looking for it for many days!!

  147. Wonderful addition to my blog! Your tutorial is just perfect and you've shared many clues in your response to comments that helped in restyling it as I wish.
    Thank you so much for this awesome Related Posts Widget, Aneesh!
    God bless you for your generosity.

  148. Cool enough.. :^) i mean it's great except that i can't find a solution to customize it, some style seems locked from the script, i don't know..

  149. hey plzz help me its not working for my blog
    Only Related Posts Heading is coming under that no posts are coming
    Please once check my blog
    please its very urgent for me

  150. hey plzz help me its not working for my blog
    Only Related Posts Heading is coming under that no posts are coming
    Please once check my blog
    please its very urgent for me

  151. thanks! this one worked on mine lol dunno how to italicize the posts though like yours ^^

  152. Hi Aneesh,

    How do you remove the line separating the related posts (instead of adding the space between the lines)?

    Thanks in advance!

  153. hi admin ...

    how to add "you might also like" widget like your ??

    its so beautiful..
    please notice me via email..
    thanks before
    :)

  154. not working for me .. i m using langit template in which i haven't found post footer line 1 ,, it has line 2 or line 3...please guide me..

  155. Oh never mind. I have found out how to remove the lines. You just need to remove border-top 1px dashed-lines from #ArchiveList ul.flat li.

    @statryacode: change the "Related Posts" into "You Might Also Like" from "var relatedpoststitle="Related Posts";"

    @vikram: if you give your site link, I can help. Just search for the words like 'footer' near the end of your CSS.

  156. Thank you very much for your widget. It work on my blog

  157. Ikhsan^Outbreaks^BloggerAugust 14 at 12:43 PM

    Looks Great! Gonna Try it. Thanks in advance

    Ikhsan

  158. Thank You,Its working. Best so far I had tried

  159. hy bro thanks for this
    but you add this code also bcoz some tamplate have this option
    my own also like this. stip one is okay but the step 2 past here

    "Step 2"

  160. I removed the b: tags as indicated in the above comments, but the related posts are still not showing on the main page. Could you please advise? Thanks!

  161. Great Post! This is going to be very helpful for every blogger

    Arigato! :D

  162. MyPersonalFinanceAugust 22 at 5:25 PM

    Hi, it doesn't work on my site, could you please check, I have followed both the steps.

  163. nice widget working on my blog

  164. i like this, thanks be4. but related articles on my blog goes wrong, usually there but now even to disappear. why ?

  165. nice post. thanks be4
    angga

  166. Mantap... I have just implemented on my new blogspot Thanks for this very helpful post :) Merdeka!!!

  167. thanks you very much for this widget/plugin

  168. thank's, awesome article. i want to try this at my blog :)

  169. I have use this code but I face some problem so can you please solve out this.

  170. Henry CaballeroOctober 2 at 9:41 AM

    Hello, I would like to ask for the code on how to add some thumbnail for each related link or post when listed. Thank you. :)

  171. I want to say just a word "Awesome". Thanks.

  172. It works! Thank you

  173. Balaji VaraprasadOctober 12 at 6:23 PM

    i have followed your instructions.
    but this is not working for my blog..
    could u please help me in this regard.
    you reply is most valuable to me..

  174. thanks alot, this post helped me alot :)

  175. Your widget does not seem to work in my blog. I would be grateful if you could have a look. Thanks in advance.

  176. hello..its not working on my blog....
    help me..

  177. Hey thank you! it works well on my blog , i just needed to remove the green tick, and i did It works well. thank you for the help :)

  178. Thank you for the widget.

  179. thanks for the information! I want to ask? how do I change the color of the letters in the related posts are displayed? from blue to black as well as letters from the "Arial"? Thank you.

  180. this shit doesnt work

  181. Great!! Now, I've had new related posts...
    Thanks a lot...

  182. That is so great! thanks a lot!

  183. thank you very much! it's working!!

  184. how to put this widget in sidebar?

  185. Rumah Jual BaliNovember 12 at 8:16 AM

    Installed the code on my blog. I see the related posts immediately after publishing then they disappear. Can't figure out what I'm doing wrong. If you could take a look, I would appreciate it.

    Thanks.

  186. Hi there,
    I've tried implementing this widget into my blog but it's not showing at all. Have followed directions and have added both parts of the code.

    My blog here:

    Any help is appreciated :)

  187. hiAness, can you please check why it's not working, i will be so greatful

  188. Hi, this isnt working for my blog either :(

  189. hey... i applied the whole procedure but the widget is not being shown. the template was saved successfully. but the related posts are not shown. Can you help me here?
    the blog

    waiting for your response.....

  190. This is such a treat and so easy! Love love love love it thx!!
    Check out my personalization :P
    Cheers all,

  191. hey... i applied the whole procedure but the widget is not being shown. my minima template was saved successfully. but the related posts are not shown. Can you help me here?
    the blog
    waiting for your response.....
    tnx in advance

  192. Edward AntrobusDecember 11 at 8:39 PM

    Is there a way to block posts with certain words in their title from appearing? I post weekly to-do lists on my blog but I don't want them appearing in the related posts section.

  193. I wish I could hug you. You are truly the best. Thanks for all that you do! :)

  194. That's wonderful ! I'm using on my blog. Thanks you very much !

  195. @HHJ-Rauney,ITechMaz - thanks for the kind words.

  196. Berondong JagungDecember 18 at 3:14 PM

    thank you......

  197. Thank you very much iam using this widget for my blog.
    it is very useful and helpful once again thank you

  198. It really works!!, very nice and very clean!!!!!
    if you want to see it working nice.

  199. Thank you for this! I used it before and it worked... but after I changed my template and put this code in again it's not working any more! The two posts on the side have the same labels... Please help me!

  200. May be i`am late to see this articles, but really thanks to the author