Recent Comments Widget For Blogspot Users

Releasing the Recent Comments widget for blogspot/blogger users.

How is it different from the other Recent Comments widget?

The problem with other widgets is that the source code for them lies with the widget author and the authors often integrate it in within their own site. If because of some problem their site is down, the recent comments widget will not work.

Here, I am releasing the source code so that the logic would reside within your blog itself and hence you can do away with dependency on 3rd party site not under your control.

How to install Recent Comments widget for blogger?

  1. Login to the blogger dashboard.
  2. Go to ‘Page Elements’ tab spacer
  3. Click on Add a Gadget. Select HTML/Javascript widget type. spacer
  4. Now this is the most important step. Select the whole code given below and paste it in the widget box you have just opened above.
    <script style="text/javascript">
    function showrecentcomments(json) {
      var numcomments = 5;
      var showcommentdate = true;
      var showposttitle = true;
      var numchars = 100;
    for (var i = 0; i < numcomments; i++) {
        var entry = json.feed.entry[i];
        var alturl;
        if (i == json.feed.entry.length) break;
    for (var k = 0; k < entry.link.length; k++) {
          if (entry.link[k].rel == 'alternate') {
            alturl = entry.link[k].href;
            break;
          }
        }
       alturl = alturl.replace("#", "#comment-");
       var postlink = alturl.split("#");
       postlink = postlink[0];
       var linktext = postlink.split("/");
       linktext = linktext[5];
       linktext = linktext.split(".html");
       linktext = linktext[0];
       var posttitle = linktext.replace(/-/g,"");
       posttitle = posttitle.link(postlink);
       var commentdate = entry.published.$t;
       var cdyear = commentdate.substring(0,4);
       var cdmonth = commentdate.substring(5,7);
       var cdday = commentdate.substring(8,10);
       var monthnames = new Array();
       monthnames[1] = "Jan";
       monthnames[2] = "Feb";
       monthnames[3] = "Mar";
       monthnames[4] = "Apr";
       monthnames[5] = "May";
       monthnames[6] = "Jun";
       monthnames[7] = "Jul";
       monthnames[8] = "Aug";
       monthnames[9] = "Sep";
       monthnames[10] = "Oct";
       monthnames[11] = "Nov";
       monthnames[12] = "Dec";
       if ("content" in entry) {
         var comment = entry.content.$t;}
       else
       if ("summary" in entry) {
         var comment = entry.summary.$t;}
       else var comment = "";
    var re = /<\S[^>]*>/g;
       comment = comment.replace(re, "");
    document.write('<br/>');
       if (showcommentdate == true) document.write('On ' + monthnames[parseInt(cdmonth,10)] + ' ' + cdday + ' ');
    document.write('<a class="' + alturl + '">' + entry.author[0].name.$t + '</a> commented');
       if (showposttitle == true) document.write(' on ' + posttitle);
    document.write('<br/>');
    if (comment.length < numchars) {
    document.write('<i>');
             document.write(comment);
    document.write('</i>');}
       else
            {
    document.write('<i>');
             comment = comment.substring(0, numchars);
             var quoteEnd = comment.lastIndexOf("");
             comment = comment.substring(0, quoteEnd);
    document.write(comment + '...<a class="' + alturl + '">(more)</a>');
    document.write('</i>');}
    document.write('<br/>');
      }
    document.write('<br/>');
    }
    </script>
    <script src="/img/spacer.gif"> xyz.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
    </script><a class="reviewofweb.com/blogging/recent-comments-blogspot-widget/">Widget </a>by <a class="reviewofweb.com/">ReviewOfWeb</a>
  5. Scroll down to src="/img/spacer.gif"> xyz.blogspot.com and replace xyz with your blog’s name. For example if your blog’s URL is abc.blogspot.com then the code should become src="/img/spacer.gif"> abc.blogspot.com DO NOT TOUCH any other part of the code or else it might create problems.
  6. You are done! Lastly please do not remove the footer credits*.

Please let me know if you face any problem implementing the code above.

*The code is released under the condition that footer credits should remain intact.

Welcome to Review Of Web. I recommend you to subscribe via RSS Feed. You can also subscribe by email and have new articles sent directly to your inbox. It's absolutely free!

Related posts:

  1. Blogspot: New Recent Comments Widget 2.0
  2. Recent Posts Widget for Blogspot Users
  3. Two blogspot tricks that can increase your traffic overnight
  4. How to make a blogspot blogroll nofollow?
  5. Make a sticky post in blogspot

September 25th, 2008 Blogging, how to

83 Responses to “Recent Comments Widget For Blogspot Users”

  1. 43 Hand Picked Tools for Bloggers | Review Of Web says:
    October 22, 2008 at 10:43 AM

    [...] Recent Comments Widget For Blogspot Users with Source Code [...]

  2. spacer Missy says:
    October 24, 2008 at 9:44 AM

    Thanks, it looks great on my blog

  3. spacer Figment Engine says:
    November 6, 2008 at 10:00 PM

    Created a widget to show blogger label co-occurance as a silverlight dynamic tag cloud

  4. spacer Daren says:
    November 8, 2008 at 8:31 PM

    I have added the link but no comments are coming up on it???

  5. spacer Daren says:
    November 8, 2008 at 8:39 PM

    It’s OK I sorted it!!! Thanks!!!

  6. spacer Frances says:
    November 13, 2008 at 7:27 PM

    Thanks so much – finally a great-looking comments widget that works on my complicated template.

  7. spacer gejza says:
    November 16, 2008 at 11:19 PM

    thnx a lot

    • spacer professional seo says:
      July 14, 2010 at 12:40 PM

      Thanks dear

  8. spacer Mat says:
    November 19, 2008 at 11:15 AM

    Thanks for this!

  9. spacer stare gry says:
    November 25, 2008 at 6:35 PM

    dzieki , dobry artykul

  10. spacer mamen says:
    December 4, 2008 at 1:12 PM

    Thank’s for u info

  11. spacer SearchingWellness says:
    December 19, 2008 at 11:53 AM

    Many thanks for this! This is the only recent comment widget that works! Keep up the good work.

  12. spacer Gennita says:
    December 20, 2008 at 6:09 AM

    I’m not sure whether it’s my site or Blogger, but all the Recent Comments widgets I’ve been trying just post comments from September and nothing recent. This started sometime early this morning EST and I have no idea how to solve it. I uninstalled my old one and installed yours, hoping that it being JS on my site would take care of the problem, but to no avail. But it’s still just showing Sept. comments! Can you help, please?

  13. spacer Rhoda says:
    December 22, 2008 at 2:41 AM

    Same problem as Gennita. This just started a couple of days ago & all the Recent Comment widgets I have tried are all pulling comments from January 2008. I would love to fix this ASAP. None of the widgets seem to be working properly & I see I’m not the only one with the problem.

  14. spacer ROW says:
    December 22, 2008 at 10:17 AM

    @Gennita and Rhoda:
    Have you followed the exacts steps as above? I just saw my test installation again, it is working perfect. Moreover you can check other bloggers who have commented above (like ky-justanotherstupidblog.blogspot.com/) for them also the widget is working fine.

    Please try it out again.

  15. spacer Gennita says:
    December 28, 2008 at 5:39 AM

    Hi ROW,
    It seems that there are a bunch of bloggers with this problem. See the following thread on blogger forum:

    groups.google.com/group/blogger-help-troubleshoot/browse_thread/thread/b5d9c0bff84c4694/62311f0d80cf3f8e

    We’re all waiting for some kind of update but it being the holidays, maybe the techies are skiing in Aspen or something spacer .

  16. spacer Taz says:
    January 4, 2009 at 8:26 PM

    Finally one that works!! Thank u!

  17. spacer ROW says:
    January 5, 2009 at 12:59 PM

    @Taz: Welcome!

    @Gennita: I looked into it again. The code is fine. It seems Google has recently messed up with comments feed and some of the blogspot bloggers are affected due to this. [knownissues.blogspot.com/2008/12/comments-feed-not-updating-1562053.html] I think the best way out is to ‘wait-and-watch’ till blogger team issue a fix.

    Having said that, for some blogs(like one of mine and some others who commented above) it is still working perfect.

  18. Recent Posts Widget for Blogspot Users | Review Of Web says:
    January 5, 2009 at 10:07 PM

    [...] and have new articles sent directly to your inbox. It doesn’t cost you anything!We had released Recent Comments Widget sometime back that turned out to be an instant hit. We were overwhelmed with the responses we [...]

  19. spacer gapsky says:
    January 27, 2009 at 8:43 PM

    thx a lot.
    it’s so useful

  20. spacer kouretinho says:
    March 2, 2009 at 8:16 PM

    thanx mate. Great easy-to-use widget! Made my day

  21. spacer Dalina says:
    April 20, 2009 at 1:26 AM

    Thanks for the widget!!
    I would like to know how I can change the Font and font size
    Any help?

  22. spacer La Huerita says:
    April 21, 2009 at 3:07 AM

    Thanks for this, it’s great! I have one problem with it: When you click on the “More” link it takes you to the post connected to the comment, not to the comment itself. Is there a way to fix this so the link goes directly to the comment?

  23. spacer Aditi says:
    May 2, 2009 at 3:14 PM

    It’s working fine. Thank you for this widget. God bless.

  24. spacer Eskapisminda says:
    May 7, 2009 at 3:50 PM

    Hi, how do I adjust the comments to ONLY showing the title not the snippets of content? thanks

    • spacer ROW says:
      May 8, 2009 at 9:47 PM

      @Eska: You “ll need to delete a chunk of code. Remind me if you’re not able to do this on your own.

  25. spacer French Tutoring says:
    May 8, 2009 at 9:44 PM

    Yes that worked! Thanks so much. Now if only I can find a Recent Posts widget that works!

    • spacer ROW says:
      May 8, 200
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.