How To Display The Number of Comments On Your Blog
29.04.09 by Jerome in Tutorials
If you have a popular WordPress blog with lots of comments, you should promote how popular it is by displaying the total number of comments you have since you started blogging on your header or sidebar.
Thanks for PhpMagicBook for coming up with an easy way of showing the total number of comments.
Drop the following code where you want to display the total number of comments:
<?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); if (0 < $numcomms) $numcomms = number_format($numcomms); ?>
And to display this number:
<?php echo "There's ".$numcomms." total comments on my blog"; ?>
This should show you how many comments your blog has got since you started.






