Counting Author Comments
-
I am trying to add the Vistor’s total number of comments beside their info. (name + date/time) in the comment’s list.
Here is the SQL that I am using:
$count = $wpdb->get_var( 'SELECT COUNT(comment_ID) FROM '. $wpdb->comments. ' WHERE comment_author_email = "' . get_comment_author_email() .'" AND comment_approved = "1" AND comment_type NOT IN ("pingback", "trackback")' //AND comment_type IN ("comments","")' //AND comment_type=""' );
Basically The Author’s email will be checked and the total number of comments will be displayed. But also I want only approved comments to be counted and also I don’t want pingbacks/trackbacks to be counted. Regardless what combination of comment_type parameter I use the code still displays a number for the pingbacks/trackbacks (sometimes the count is 13 and sometimes it is 41, the number is wrong).
I tried to use the function check_comment(), i could not get it to work to leave out trackbacks/pingbacks from being counted. Here is an image of the results (notice the count on the pingback. There shouldn’t be anything there):
https://bacsoftwareconsulting.com/blog/wp-content/uploads/2012/07/comment-counter-per-author.jpgAny help is appreciated. Thanks.
- The topic ‘Counting Author Comments’ is closed to new replies.