Thursday, July 22, 2010

TutZone- Tutorials, Design news and Inspiration

TutZone- Tutorials, Design news and Inspiration

Link to TutZone

Display the Total Number of Comments on Your WordPress Blog

Posted: 22 Jul 2010 06:54 AM PDT


Ever wondered on how to show total number of comments posted on your blog without manually updating the count. This simple hack will help you display total number of comments on your WordPress blog. Hope you find it useful.

comment count code

One Step Tutorial:

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";
?>

That’s it.

No comments:

Post a Comment