How To get Blogger Total Number of Posts and Comments

You can add the total number of posts and comments as a blogger gadget. In your design page, add an HTML/Java Script gadget, and put in the following code:

<script>
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>
<script src="http://your.blogspot.com/feeds/posts/default?alt=json-in-script&amp;callback=numberOfPosts"></script>
<script src="http://your.blogspot.com/feeds/comments/default?alt=json-in-script&amp;callback=numberOfComments">
</script>


the function numberOfPosts(json) and function numberOfComments(json) will be called by your blogger script when the page is loaded.

that's it !






Post a Comment