Skip to main content
5 votes
Accepted

Exclude comments from a WP_Query object?

Did you actually find a case where there are any real comments in the wp-query object after running a normal query? If you examine the code in class-wp-query.php, you should find that the comments ...
Otto's user avatar
  • 32.6k
4 votes
Accepted

Custom WP_Comment_Query with pagination and orderby?

The goal was to paginate comments, showing comments with the highest comment_rating meta value first. Thanks to the answer of cjbj and the comments by Milo and birgire I figured out the rather ...
Swen's user avatar
  • 1,374
3 votes
Accepted

How to query comments only for the current post?

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' => ...
Johansson's user avatar
  • 15.3k
3 votes
Accepted

WP_Comment_Query with 5 top level comments per page?

Updated The hierarchical parameter controls whether to include comment descendants in the comments results. From the inline docs we have that it accepts the following values: 'threaded' ...
birgire's user avatar
  • 67.1k
2 votes

Custom WP_Comment_Query with pagination and orderby?

If you take a look at the wp_comment_query class, you'll see there is no parameter paged. If you then look at wp_list_comments, which does allow pagination, you'll see that it calls a lengthy walker ...
cjbj's user avatar
  • 14.5k
2 votes
Accepted

How to make comments private for commentor and post author

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'...
Tom J Nowell's user avatar
  • 59.3k
1 vote
Accepted

Comment Table Size Results in Slow Page Loads and 500 Errors

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 ...
Rick Hellewell's user avatar
1 vote
Accepted

How is the author's name given a different color?

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
Tom J Nowell's user avatar
  • 59.3k
1 vote

How to put this result inside that result?

Run the loop in advance and populate an array, which in turn you include in the $result afterward. <?php // Create an empty array $comlistall = array(); foreach ( $comments as $comment ){ $...
Tobias's user avatar
  • 128
1 vote

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

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', ...
Johansson's user avatar
  • 15.3k
1 vote

Trying to get property of non-object notices in comment-template.php

This notice comes because object $comments is null. So the have_comments() must wrap all the thing to be sure there are comments before using any property. in your case : <?php if ( have_comments(...
JMau's user avatar
  • 2,913

Only top scored, non community-wiki answers of a minimum length are eligible