<script src="http://www.lawnydesigns.com/feeds/posts/default?alt=json-in-script&callback=numposts"></script>
<script src="http://www.lawnydesigns.com/feeds/comments/default?alt=json-in-script&callback=numcomments"></script>in the code above we have asked blogger to return our JSON feed to two javascript functions named
numcomments and numposts so now we will create those two functions to print out the total post and comments count<script style="text/javascript">function numposts(json) { document.write('This blog has ' + json.feed.openSearch$totalResults.$t + ' posts'); }function numcomments(json) { document.write(' and ' + json.feed.openSearch$totalResults.$t + ' Comments'); }</script>now if you paste the two sets of code together into an html/javascript widget and you followed this tutorial right you should see something like my result below
of course your numbers will be different so now you know how to print out the total post and comment count on your blog i hope you enjoyed this tutorial feel free to leave you comment or suggestion



7 Responses to “How to display total post and comment count on blogger”
Anonymous
March 20, 2009Thanks lawny just what i was looking for
netpicker
May 01, 2009is there a way to display the number of comments per post on the sidebar - labels widget can display the post name but not the number of comments per post.
Lawny
May 04, 2009@netpicker
it is possible but i don't have a script to display the comments in the sidebar
suhey
September 08, 2009i will try your code to my blog! thanks
Blog Amrih-G
September 19, 2009I will try too.
Netpicker--
you can try below code to display each post title and its corresponding comment(s). This script to create recent post in side bar.
For the example, click here..>>
<em>
<script language="JavaScript">
imgr = new Array();
imgr[0] = "http://i43.tinypic.com/orpg0m.jpg";
imgr[1] = "http://i43.tinypic.com/orpg0m.jpg";
imgr[2] = "http://i43.tinypic.com/orpg0m.jpg";
imgr[3] = "http://i43.tinypic.com/orpg0m.jpg";
imgr[4] = "http://i43.tinypic.com/orpg0m.jpg";
showRandomImg = true;
boxwidth = 190;
cellspacing = 8;
borderColor = "#110906";
bgTD = "#000000";
thumbwidth = 30;
thumbheight = 30;
fntsize = 12;
acolor = "#999";
aBold = true;
icon = " ";
text = "comments";
showPostDate = false;
summaryPost = 200;
summaryFontsize = 10;
summaryColor = "#ccc";
icon2 = " ";
numposts = 7;
home_page = "http://amrihgunawan.blogspot.com/";
</script>
<script src="http://myblogtalk.com/bloggertemplates/js/recentposts_thumbnail.js" type="text/javascript"></script>
</em>
Harwinder a.k.a. Brain Washer
November 09, 2009Thanks for the tip.
Initially it didn't work for me, but after reversing the order of the scripts, it worked. Probably, you might want to mention in your post that the order is important.
Lawny
November 10, 2009@Harwinder
not sure what you mean but it should work either way
Leave a Reply
Feel free to leave your comment however comments are moderated before appearing on site