Show the number of comments next to the username
Add code snippet to functions.php your topic WordPress. Open your comments.php in the current template template and put the second fragment in it commentCount ().
1 2 3 4 5 |
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'; } |
To display the number of comments add this code commentCount() to user exit location. The number of user comments will be displayed next to him.
1 2 3 |
<?php commentCount(); ?> |
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.