Home » Labs » How to display total number of comments on WordPress blog  

How to display total number of comments on WordPress blog


Filed under Labs

Place below code in your WordPress template where you want to display the total number of comments on WordPress blog.

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

Posts you may like: