prevent get_comments() from returning comments not in comment__in
prevent get_comments() from returning comments not in comment__in
prevent get_comments() from returning comments not in comment__in
comment_post (if comment is approved OR $comment_approved === 1) not working?
The solution to the issue of slow queries on a site that has a very active comment ‘gang’ (there are over 150K comments on that site, with about 50-100 added each day) (sort of a long answer, but the details might help others): The first step was to ask the hosting company to move the … Read more
Yes, a quick search of developer.wordpress.org reveals comment_feed_where. Note that this won’t work with get_posts unless suppress filters is turned off, and that what you’re trying to do is going to be very slow with some unreliability. There is also comment_clauses: https://developer.wordpress.org/reference/hooks/comments_clauses/
You wrote .comment-list but that’s not the class, it’s .commentlist. You may also need to target the anchor link inside that tag explicitly to override link colours
You can use the pre_get_comments filter to modify the parameters of the comment query before it fetches the comments. Specifically the author_in parameter. I tried to write an example, though I haven’t tested it, but it would be similar to this: add_action( ‘pre_get_comments’, ‘author_and_self_comment_filter’ ); function author_and_self_filter( \WP_Comment_Query $query ) : void { // We … Read more
Try with WP_Comment_Query and make sure you have the right Author ID from the Author Template. // WP_Comment_Query arguments $args = array ( ‘user_id’ => $user->ID, ‘post_status’ => ‘approve’, ‘number’ => ’10’, ); // The Comment Query $comments = new WP_Comment_Query; $comments = $comments->query( $args ); // The Comment Loop if ( $comments ) { … Read more
Your arguments for the comment query is empty, so it returns every comment on the planet. You should specify the post ID, to get comments that belong to that post. $args = array( ‘post_id’ => get_the_ID(), ); Take a look into the codex page for more information about arguments.
This should do the trick, I guess: $args = array( ‘number’ => 10, ‘order’ => ‘DESC’, ‘status’ => ‘approve’, ‘parent’ => 0 ); $comments = get_comments( $args ); You can find full list of arguments in Codex.
You should be able to do a meta_query in a WP_Comment_Query(): $args = array( ‘post_id’ => ‘post-id-here’, ‘meta_query’ => array( array( ‘key’ => ‘fish’, ‘value’ => ‘shark’, ‘compare’ => ‘LIKE’ ) ) ); // Query the comments $comment_query = new WP_Comment_Query( $args ); // Count the number of comments $count = count ( $comment_query ); … Read more