Hello! I followed the tutorial from this website to make a call to display user total comment number but I don't know where I have to put the php call... Can you please tell me which template I have to put this call? <php commentCount(); ?> Of course, I already put this content under the template function.php
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';
}
I think you've done something incorrect. Maybe you've added this code in other function or class. Or maybe the file you've put it is not the MAIN current active theme functions.php . The functions.php is located on the root of the theme folder.
Make sure you've put it on end of functiosn.php file:
It should look like this, we just tested this code:
There is a class="wpdiscuz-comment-count" if you want to style this part:
I think you've done something incorrect. Maybe you've added this code in other function or class. Or maybe the file you've put it is not the MAIN current active theme functions.php . The functions.php is located on the root of the theme folder. Make sure you've put it on end of functiosn.php file:
It should look like this, we just tested this code:
There is a class="wpdiscuz-comment-count" if you want to style this part:
It works, thank you. 🙂
However, how do I change the name of "comments" to another language?
There is a problem with the code to show Total coments beside username. The Total comments only display for registered user, it does not display total comments guest user.
Could you please modify the code and make it work for everyone including guest author?