Quantcast
Channel: HTML – iTechColumn
Viewing all articles
Browse latest Browse all 17

How to display total comment count in Blogger

$
0
0

How to display total number of comments in Blogger. USING TOTAL NUMBER OF COMMENTS & TOTAL NUMBER OF POSTS ON BLOGGER TOGETHER.

How to display total comment count in Blogger

In our previous post, we saw how to display total number of posts in Blogger. Today, I could like to show you guys on how to display the total number of comments on Blogger. Displaying the total number of comments on Blogger is equally important as displaying posts on Blogger. We can display the total number of posts and comments on the sidebar or anywhere desirable.

Easily Display total comment number count in blogger

Before this post ends, We will see on how to show total number of comments and total number of posts at a time side by side.

Similar to the last post on displaying total post count, we will see what is the feed for comment on Blogger:

Comment feed URL:
Atom Feed: http://www.yourblogname.com/feeds/comments/default
RSS Feed: http://www.yourblogname.com/feeds/comments/default?alt=rss

Replace www.yourblogname.com with your site name or blogspot name.

Now, we will see the tutorial:

1. Go to Dashboard > Layout > Add a Gadget

2. Select HTML/JavaScript gadget.

3. Paste the following code directly below:

<script style=”text/javascript”>
function commentscount(json) { 
document.write(‘This Blog has <b>’ + json.feed.openSearch$totalResults.$t + ‘ Comments</b>’); 
</script>
<script src=”http://www.YOURSITENAME.com/feeds/comments/default?alt=json-in-script&callback=commentscount”></script> 


Replace YOURSITENAME with your actual site name or blog name.

4. Save the widget and view the number of comments on your Blog.

You are done!!
_______________________________________________________

TUTORIAL for showing both number of comments and posts at the same time:

How it looks:

 

1. Follow the steps above till step 2.

2. Paste the following code directly below:

<script style=”text/javascript”>
function postscount(json) { 
document.write(‘This blog has <b>’ + json.feed.openSearch$totalResults.$t + ‘ posts</b>’); 
}
function commentscount(json) { 
document.write(‘ and <b>’ + json.feed.openSearch$totalResults.$t + ‘ Comments</b>’); 
}
</script><script src=”http://www.YOURSITENAME.com/feeds/posts/default?alt=json-in-script&callback=postscount”></script><script src=”http://www.YOURSITENAME.com/feeds/comments/default?alt=json-in-script&callback=commentscount”></script>


Replace YOURSITENAME to your blog or site name.

3. Save the widget and view the number of comments and posts at the same time. You are done!
_________________________________________________________
Customization:

If you like this way to display:


The paste this code in HTML/JavaScript gadget:

<script style=”text/javascript”>
function postscount(json) {
document.write(‘Total Posts: <b>’ + json.feed.openSearch$totalResults.$t + ‘ posts</b><br/>’);
}
function commentscount(json) {
document.write(‘ Total Comments: <b>’ + json.feed.openSearch$totalResults.$t + ‘ Comments</b>’);
}
</script><script src=”http://www.itechcolumn.com/feeds/posts/default?alt=json-in-script&callback=postscount”></script><script src=”http://www.itechcolumn.com/feeds/comments/default?alt=json-in-script&callback=commentscount”></script>



You are completely done 🙂
Thanks for reading.. Hope you like this post 🙂

The post How to display total comment count in Blogger appeared first on iTechColumn.


Viewing all articles
Browse latest Browse all 17

Trending Articles