Sunday, May 17, 2009

Show total posts - total comments script widget

On right hand side column of this blog traffic tips blog you can see total number of posts and total number of comments.

How to show total number posts and/or total number of comments on your blogger blog ?

Here is script to show total number of posts and comments . You have to add this java script
by going to Dashboard > Layout > Add a gadget > HTML /Java script

Then copy following java script .

Please change blog url from www.blogtraffictips.net to yourname.blogspot.com in the following script.


<script src="http://www.blogtraffictips.net/feeds/posts/default?orderby=published&alt=json-in-script&callback=rp"></script>

<script style="text/javascript">
function numberOfPosts(json) {
document.write('Total number of Posts: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}
</script>
<script src="http://www.blogtraffictips.net/feeds/posts/default?alt=json-in-script&callback=numberOfPosts"></script>




<script src="http://www.blogtraffictips.net/feeds/comments/default?orderby=published&alt=json-in-script&callback=rp"></script>

<script style="text/javascript">
function numberOfComments(json) {
document.write('Total number of Comments: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}
</script>
<script src="http://www.blogtraffictips.net/feeds/comments/default?alt=json-in-script&callback=numberOfComments"></script>


The first half can be used to display only total no. of posts and second half can be used to display only total no. of comments.

9 comments:

Richard said...

Great! Thanks for sharing this script widget, this is exactly what I need. Thanks for sharing and I'll try it out for myself.

Southern California website design

Russel said...

Thanks for your nice tips. I love your blog.

Blogger Tips

Russel said...

Thanks for your nice tips. I love your blog.

Blogger Tips

urdublog said...

Thanks :)

Jennifer said...

Thanks for this widget...I'm having a problem with it though. I have had it up for a few months and then all of the sudden it is showing incorrect numbers for my comments. My comments are around 800, and it is only showing 81. I've tried removing it and adding it back on, but it isn't resolving the problem. Any ideas what could be the issue?

Blog Rasmi YM Syed Abi Ghufran Al-Idrus said...

hai there..this widget is not working in my blog..why??

gameboy said...

thanks the widget works fine for my blog
www.hacknol.blogspot.com

resell-rights-hub said...

Thank you I'll give it a try ASAP and if it works I'll re-comment on the script.

Meleca Cristian said...

thanks for script :D