13
Aug
Display comment count of logged in user
- Category:
- Wordpress

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
View Code PHP
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
View Code PHP
1 | <?php commentCount(); ?> |
Screenshot :
- Tags: