How to Add Total Posts / Comments Counts to Blogger

Do you want to show the number of total posts and comments of your Blogger powered blog? If yes, then this simple trick is definitely what you are looking for. This simple tool works by using JavaScript, which function is to count your the total number of posts and comments based on your feeds. Here is an example of such widget:

Total Posts: 180
Total Comments: 244

Interested? Here are the step by step guide on how to create such gadget:

1. Login to Blogger.com,
2. Visit you dashboard >> layout >> page elements.
3. Click "Add a Gadget", choose HTML/JavaScript.
4. Paste these codes there, change the bold ones with your blog address:

<script style="text/javascript">

function numberOfPosts(json) {
document.write('Total Posts: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}

function numberOfComments(json) {
document.write('Total Comments: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}

</script>

<font color="blue">

<script src="http://your-blog-name.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts"></script>

<script src="http://your-blog-name.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments"></script>

</font>

5. Save and done.

Visit your blog to check the counts. If you are quite savvy with JavaScripts, feel free to customize it. Let me know if your need further assistance.

3 comments:

Powen said...

Thanks alot^^b

Margaret said...

What a helpful blog you have. I'll be sure to check in again. Thanks for visiting my blog.

Isaac Yassar said...

You're welcome folks. Always a pleasure.