How to Display Recent (Most Commented) comments in Blogger

 How to Display Recent comments in Blogger

Why to Add Recent Comments Widget in Blogger?

You might have an active community on your blog, where people often leave a comment or two on your multiple posts. However, people who leave comments on your blog are actually your followers as you don’t really see new people commenting on your blog posts unless they need help.  So, this widget could help new visitors in motivating them to take part in the conversation which would certainly increase the engagement as well.

How to Add Recent comments in Blogger?

The very first thing that you’ll be doing is to login into your blogger dashboard with your Google account. After logging in go to Layout >> Add a Gadget >> Add HTML/JavaScript and paste the following piece of coding that will turn into a list of recent comments on your blog.

<script type="text/javascript">
var a_rc = 5;
var m_rc = false;
var n_rc = true;
var o_rc = 100;
function showrecentcomments(e){for(var r=0;r<a_rc;r++){var t,n=e.feed.entry[r];if(r==e.feed.entry.length)break;for(var i=0;i<n.link.length;i++)if("alternate"==n.link[i].rel){t=n.link[i].href;break}t=t.replace("#","#");var a=t.split("#");a=a[0];var c=a.split("/");c=c[5],c=c.split(".html"),c=c[0];var s=c.replace(/-/g," ");s=s.link(a);var o=n.published.$t,l=(o.substring(0,4),o.substring(5,7)),u=o.substring(8,10),m=new Array;if(m[1]="Jan",m[2]="Feb",m[3]="Mar",m[4]="Apr",m[5]="May",m[6]="Jun",m[7]="Jul",m[8]="Aug",m[9]="Sep",m[10]="Oct",m[11]="Nov",m[12]="Dec","content"in n)var d=n.content.$t;else if("summary"in n)var d=n.summary.$t;else var d="";var v=/<\S[^>]*>/g;if(d=d.replace(v,""),document.write('<div class="rcw-comments">'),1==m_rc&&document.write("On "+m[parseInt(l,10)]+" "+u+" "),document.write('<span class="author-rc"><a href="'+t+'">'+n.author[0].name.$t+"</a></span> commented"),1==n_rc&&document.write(" on "+s),0==o_rc)document.write("</div>");else if(document.write(": "),d.length<o_rc)document.write("<i>&#8220;"),document.write(d),document.write("&#8221;</i></div>");else{document.write("<i>&#8220;"),d=d.substring(0,o_rc);var w=d.lastIndexOf(" ");d=d.substring(0,w),document.write(d+"&hellip;&#8221;</i></div>"),document.write("")}}}
</script><script src=http://www.mybloggerlab.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments ></script>
<style type=text/css>
.rcw-comments {
font-family: inhert;
font-size: 14px;
margin-bottom: 15px;
border-bottom: 1px solid #d2d2d2;
padding-bottom: 15px; line-height: 20px; }
}
</style>

You need to replace your Website URL, so that this widget will work just fine. To increase the number of comments shown on the widget simply search and replace “5” with the no of comments on you want to show.  If you like to display dates along with comments than replace “False” with true. If you want to limit comment characters then replace “100” with any other that you like.

After customizing you can save the widget by pressing "Save" button present towards the end of the widget. Once done, you will be able to see recent comments on your blog.

We hope this tutorial may have helped you in learning how to display recent comments in blogger. We have used JavaScript to display these comments, so if you turn off JavaScript from your browser's setting it will stop appearing. However, almost 99% browser nowdays support JavaScript, so its not a that big issue. Let us know what are your thoughts about it, share it with your friends on Facebook, Google+ or Twitter.


How to Display Most Commented Posts in Blogger


The very first thing you need to do is to login to your blogger account with the help of your Gmail ID and password. Once you are successfully entered to Blogger Dashboard, go to Layout >> Sidebar >> Add a gadget >> Add HTML/JavaScript and in the HTML Text box paste the following piece of code:

<!-- Popular posts with comment count Start -->
<script type="text/javascript">
function getYpipePP(feed) {
 document.write('<ol style="">');
 var i;
 for (i = 0; i < feed.count ; i++)
 {
var href = "'" + feed.value.items[i].link + "'";
var pTitle = feed.value.items[i].title;
var pComment = " \(" + feed.value.items[i].commentcount + "\)";
var pList = "<li>" + "<a href="+ href + '" target="_blank">' + pTitle;
 document.write(pList);
 document.write(pComment); //to remove comment count delete this line
 document.write('</a></li>');
 }
 document.write('</ol>');
 }
 </script>
 <script src="http://pipes.yahoo.com/pipes/pipe.run?
 YourBlogUrl=http://www.mybloggerlab.com/
 &ShowHowMany=10
 &_id=390e906036f48772b2ed4b5d837af4cd
 &_callback=getYpipePP
 &_render=json"
type="text/javascript"></script>
<span style="font-size: 80%; float:right;"><a href="http://www.mybloggerlab.com/2014/06/how-to-display-most-commented-posts-in-blogger.html">Make your own</a></span>
<!-- Popular posts with comment count End -->

After pasting the above code, you need to customize it to your desire needs, so do not forget to replace http://www.mybloggerlab.com/ with your blog URL. By default, it would display 10 most commented posts so to increase or decrease the count replace =10 with the number of posts you would like to display.

Once you have finished customizing the gadget, press the “Save” button to enable the gadget in the sidebar of your blog. Congratulations, you have successfully added a list of most commented posts in your blogger blog.

We hope this article have helped all those people who kept on messaging us about this gadget. Do let us know what are your feelings and thoughts about it. In case you are already using it then let us know about how it has helped you to engage more audience. 

Post a Comment

أحدث أقدم