How to Show Total Posts & Comments


How to Restore Pencil to Edit Posts



A simple script allows us to show off total posts and comments on our blog.

Just go to Layout | Page Elements and click Add a Gadget link in your sidebar where you want to add this widget. When a new window is opened, chose HTML/JavaScript as your widget and add the following code in the Content field.



<script style="text/javascript">
function numberOfPosts(json) {
document.write('Posts: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}
function numberOfComments(json) {
document.write('Comments: <b>' + json.feed.openSearch$totalResults.$t + '</b><br>');
}
</script>
<font color="blue"><script src="http://bloggerfaqs.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts"></script>
<script src="http://bloggerfaqs.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments"></script></font>



Customization...


Replace http://bloggerfaqs.blogspot.com/ with your own blog URL. You can change the Posts: and Comments: text to whatever you like for example you can replace Comments: with Total No. of Comments:.

7 comments:

jacks said...

hi! Thanks for the sharing.. easy to download

Dorothea said...

what a great tip! thanks!

Bilal said...

@ Dorothea, help me improve this blog by making some suggestions.

fateen said...

whoa , great job

Magali said...

Lovely widget. But the blue text doesn't look harmonious with my blog. Any simple way i could make it green? Thanks in advance!
My blog: http://girlslife9.blogspot.com/

Bilal said...

Hi Magali, whoa this is so simple. In the above code, just change:

<font color="blue">

to

<font color="green">

and now you'll have the text in green!

Magali said...

Thanks Bilal!

Post a Comment