Pages

Thursday, May 5, 2011

Trick for displaying Number of Comments in your WordPress Blog


Place below code where you want to display your comment count:
<?php
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);
echo "There's ".$numcomms." total comments on my blog";
?>


0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.