Here's another simple widget for your blog. With this widget, you can show your live stats (total posts and comments on your blog).
You may change the phrases "Total Posts" and "Total Comments" and the color of the font too.
Follow these instructions to add a similar widget to your blog:
Log in to Blogger, go to "Layout", click on "Add a Gadget", and select it as "HTML/JavaScript" type. Now add this code to the widget:
<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="red"><script src="http://bloggerstop.net/feeds/posts/default?alt=json-in-script&callback=numberOfPosts"></script>
<script src="http://bloggerstop.net/feeds/comments/default?alt=json-in-script&callback=numberOfComments"></script></font>
Replace the code in red with your blog's address.
And you may change the code highlighted in blue to modify the appearance of this widget.
15 comments
Write commentsFor some reason it doesn't work on my test blog. Is it because I have another widget that does this also?
ReplyGive your blog link dude !
Replygood job.....thank's 4 share
Replyhttp://www.testblogsnam23.blogspot.com/
ReplyDude that blog's taking too much of time to load, may be because of the number of widgets in it !
ReplyAs this widget is very easy to add, and hardly takes time, so I advice you to directly try it out in the final blog where you want to put it....
Regards
Sai
I am very new to blogging but your site helped me a lot. Thanks very much. I visit your site every to get tips on how to improve my site.I follow your tips one at a time. Thanks again.
ReplyWelcome Hugo......I am glad you were here buddy !
Replythanks for your simple yet wonderful code :)
ReplySai Ram Divya,
ReplyI have been using this widget since the day it was posted. But now comments count is not working properly, I mean comments are displayed less as compared to actual ones. Please help.
Yeah that's true, and this is not limited to this widget but the count is faulty in the popular posts widget too. The problem is not with any of these widgets, rather something is wrong at Blogger itself. May be something is being edited in the feedlinks.
ReplyI am having problem with this widget. It is not showing the actual total number of comments. It was somewhere is 1000s n now it is showing it in 100s. :(
ReplyYes Shas, even I am facing that problem. And that is why I stopped using it. Actually the problem isn't with the widget but with the feed itself. Hope it's just a temporary problem.
Reply:))
Replythankx 4 the tutorial. :D
ReplySince recent changes on Google, the PageRank checking became an isue, yet it can still be checked by this free tool: http://domof.com . Use the returned seo information wisely and save it as pdf file for refference (look for a button: "Seo Report - Download").
ReplyComments are moderated on this blog
Allowed HTML tags: <b>, <i> and <a>
Comment Like This! and Optimize your blog EmoticonEmoticon