Thursday, 1 October 2009

Displaying total number of posts and comments to blogger

Many old bloggers display their total posts and comments just to show how popular their blog is. You can too add this widget to your blog. The widget looks like this:

Total Posts And Comments Widget

To add this widget follow these simple steps:

1.Go to Layout>Page Elements
2.Then click on Add Gadget

3. Then select HTML/JAVASCRIPT


4. To this add the following code:
<script type="text/javascript">
function TotalPosts(json) {
document.write('<b>Total Posts: ' json.feed.openSearch$totalResults.$t '</b>');

function TotalComments(json) {
document.write('<b>Total Comments: ' json.feed.openSearch$totalResults.$t '</b>');

<script src="/feeds/posts/default?alt=json-in-script&callback=TotalPosts"></script>
<script src="/feeds/comments/default?alt=json-in-script&callback=TotalComments"></script>

5. You can replace the bold part of the code to whatever you like. After editing save the widget and see for yourself.

No comments:

Post a Comment