Display user comment count next to username

Add the first snippet into the functions.php of your wordpress theme. Open up your comments.php template and place the second snippet commentCount() in the location you wish to display each users comment count.

 

 

<?
function commentCount() {
global $wpdb;
$count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = "' . get_comment_author_email() . '"');
echo $count . ' comments';
}
?>

<?php
commentCount();
?>

Be Sociable, Share!

Leave a comment