Add Recent Comment Widget in Blogger

Ever wanted to put a widget that shows the Recent Comments being written on your blog. My blog is to put what I learn about computers and in the process share my experience with everyone. Now continuing the purpose of this blog, I will share with you the procedure on how to add “Recent Comments” widget.

First go to layout => Edit HTML and search for

<script type='text/javascript'>
function commentDisplay(json) {
   for (var i = 0; i &lt; numcomments; i++)
       var entry = json.feed.entry[i];
       var alturl;
       if (i == json.feed.entry.length) break;
       for (var k = 0; k &lt;; k++)
           if ([k].rel == 'alternate')
               alturl =[k].href; break;
       alturl = alturl.replace("#", "#comment-");
       if (entry.content)
           comment = entry.content.$t;
       else if (entry.summary)
               comment = entry.summary.$t;
           var re = /&lt;\S[^&gt;]*&gt;/g;
           comment = comment.replace(re, "");
           document.write('&lt;a href="' + alturl + '"&gt;' +[0].name.$t + '&lt;/a&gt; commented:&lt;br/&gt;');
           if (comment.length &lt; numchars) document.write(comment + '&lt;br/&gt;&lt;br/&gt;');
           else document.write(comment.substring(0, numchars) + '...&lt;br/&gt;&lt;br/&gt;');

Now go to Layout => Page Elements and in sidebar click add a gadget and choose HTML/JavaScript and in Configure HTML/JavaScript paste the following code

<br/><script language="javascript">
var numcomments = 5;
var numchars = 50;
<script src="

Change to the address of your blog

Save the page and then view your blog. You can tweak the number of comments and number of characters in each comment as shown below.



  1. Thank you. I added this to two blogs. I had something similar before on one of the blogs, and inadvertently messed it up. I needed something to replace it, right away. This worked perfectly.

  2. Dear, I've tried this, A widget accoured also on my blog name, सर - आँखों पर but stil the recent comments r not showing. Can u pls tell me what i've done wrong ?

    Jaikaran Singh Bhadauriya


Post a Comment

Comment for encouragement

Popular posts from this blog

Configure D-Link 2750U Wi-Fi Router for Airtel

Aspire theme Problems

How to write in Hindi on Facebook