How would I count the number of times a comment meta field’s value is in a post’s entire comments?

How would I count (and display) the number of times a comment meta field’s value is a post’s entire comments? e.g. meta key is “fish” and key value “shark” appears in 5 comments of a post. 1 Answer 1 You should be able to do a meta_query in a WP_Comment_Query(): $args = array( ‘post_id’ => … Read more

WP_Comment_Query() displays “password protected” comments?

It appears that looping through wp_comment_query() with the argument post_status set to publish also lists comments that are posted on password protected posts. Is this the correct behavior or is this a bug? How can I avoid looping through comments submitted to password protected posts? I checked through the database wp_comments table and there doesn’t … Read more

Exclude comments from a WP_Query object?

I have noticed that the default WP_Query object also contains all of a post’s comments. global $wp_query; print_r($wp_query->comments); // Prints an object containing all of a post’s comments From my understanding, WordPress somehow combines a post query and a comments query into one WP_Query object, and then displays a post’s comments by reading the $wp_query->comments … Read more

Custom WP_Comment_Query with pagination and orderby?

I’m trying to setup a custom WP_Comment_Query which is ordered by a meta key. (It might be worth mentioning that these comments are being retrieved with AJAX.) It all works fine, until I add in pagination into the query args. $orderby = ‘top-comments’; $args = array( ‘post_id’ => $post_id, ‘type’ => ‘comment’, ‘status’ => ‘approve’, … Read more