There are lots of things which can be achieved in a wordpress blog, and here is another little trick I came across after some little research on wordpress themes. You may want to display the number of comments by your blog registered users and you’ve been looking for a plugin to output the number of user comment as text. Well, search no further, cos here is a little wordpress code to display the user comment count on your wordpress theme.

To display the number of user comments, simple copy and paste the below code into the part of your WordPress theme you would like it to be displaye.

Ex: Login to your WordPress Dashboard

– Click on Appearance > Editor.

– Select Footer, then in the first line, paste the code


global $wpdb;
$where = ‘WHERE comment_approved = 1 AND user_id <> 0’;
$comment_counts = (array) $wpdb->get_results(”
SELECT user_id, COUNT( * ) AS total
FROM {$wpdb->comments}
GROUP BY user_id
“, object);
foreach ( $comment_counts as $count ) {
$user = get_userdata($count->user_id);
echo ‘User ‘ . $user->display_name . ‘ comment count is ‘ . $count->total . ‘


– Now click on Update File.

This would display your wordpress number of comments by users at the blogs footer.

Hope you enjoyed this little trick.


Please enter your comment!
Please enter your name here