Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

13

Aug

Display comment count of logged in user

Display comment count of logged in user

Posted On : August 13, 2013

| No Comment

if we want to display total count for comment in wordpress for logged in user follow the below code. you need to edit your theme’s function.php file.

Code 1:

//Enter below code in theme’s function.php file

1
2
3
4
5
6
7
function commentCount() {
    global $wpdb;
    global $current_user;
    get_currentuserinfo();
    $count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = "' . $current_user->user_email . '"');
    echo $count;
}

Code 2:

//Enter below code where you want to display comment count

1
<?php commentCount(); ?>

Screenshot :

  • Tags:

Comment