This blog displays statistics on the right-sidebar (bottom) like - There are currently #### posts and #### comments in this weblog. The data is obviously dynamic.

Andre recently asked me how I do it. Here is a simple solution.

Embed the following code in your sidebar (or elsewhere) in location of your choice:

php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts); 

$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
?>


There are currently php echo $numposts ?> posts and php echo $numcomms ?> comments in this weblog. Enjoy!

You can also download the code(recommended).

Note: Make sure to copy paste exactly the code above. You may modify the message as indicated.

Note: This code has been adapted from WordPress Dashboard code.