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 field only is populated with comments when a “comments-feed” is being queried for.
In normal operation, comments are not retrieved by the WP_Query, but instead retrieved by using WP_Comment_Query, and this does not happen until your theme calls the comments_template() function.
As such, you can use the ‘comments_template_query_args’ filter to filter the arguments passed to that class before the comments are displayed on the page. This won’t affect the comments feed, because those are indeed populated by the main WP_Query, but only for the comments feed case.
Related Posts:
- prevent get_comments() from returning comments not in comment__in
- WP_Comment_Query pagination, delving into the unknown
- Get posts with condition on comment meta value
- WP_Query sort by comment meta data
- Get number of comments after modifying comment query
- using wp_query to return posts w/ comment count > 0
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Query posts with more than 20 comments
- How can I retrieve comments from last 5 minutes for a post?
- Sorting posts DESC based on the number of comments using WP_Query
- Most commented last 24h, week, month, year and all time – posts_where
- Most commented post showing 2 records
- WordPress Comments sort by custom meta key
- Query posts by last comments
- How to list posts with disabled/closed comments, with pagination?
- I need help using pre_get_comments to limit comments in the comments admin screen
- All Posts Have The Same Comments
- Is it possible to give a classname to specific comments in the WordPress admin?
- How to get_comments() ordered by date and parent?
- Comments orderby comment date not working
- How to display comments list by order when clicking on newest or oldest link?
- Get comment number by date range?
- Inherit args from the main wp_query or wp_comment_query to my custom query
- How to store and receive variables in WP sessions?
- Reduce or prevent calling of update_meta_cache
- Query Multiple Post types each with own meta query
- WP_Query min and max values
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to query posts of standard post format. For real
- Orderby menu_order doesn’t work
- WP_Query by Category Name
- assign 2 $args to one wp_query
- WP_Query OR clause for tax_query and keywords
- Transient pagination not working properly
- query posts in functions.php and update a field
- get_posts() seemingly ignoring post_type
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Which filter/action hook gets triggered after a query has been performed?
- Why query_vars get altered in WP_Query Object?
- pre_get_posts filter meta_query without conflicting existing meta_query
- How would I format a query that depends on post parent taxonomy
- Minimising Database Queries when using Advanced Custom Fields
- List only posts from specific category on category page
- Most popular post for last 7 days
- Get data of all posts of a query before pagination
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- How to avoid wp_query returning the same post I’m on in results?
- Query multiple meta values
- Why isn’t my multiple orderby working?
- WordPress Loop and $post
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- WP_Query tax query part of slug
- Query posts without meta preload
- How to implement a new row_count method in WordPress?
- reset to main loop doesnt work
- Applying posts_clauses filter to specific queries only
- Some doubts about how the main query and the custom query works in this custom theme?
- How to do a wp_query with two acf-fields, sorting on one of them
- Shortcode for latest -not expired- posts
- Get author if post has multiple authors
- Hide posts with meta key in WP_Query
- What happens to the default query when I use WP_Query?
- JSON – Create rest api endpoint for Advanced Custom Fields
- Query_vars support in Rest API
- Is it possible (and how to) query single Gutenberg blocks?
- Continue or break the while loop
- Custom query filter by ACF date custom field
- Sorting posts by Multiple custom fields in defined order
- How to build the WP_Query using the code?
- How go give $value to wp_query
- Show multiple tax_query from 2 or more post_type in a single code
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to use rewind_comments() – when and how to use it?
- How to make a query returning pages from multiple parents
- create a custom query for posts managed by Restrict Content Pro
- How do I stop the same post showing multiple times in a archive?
- Related categories order posts by category
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Order Element By Custom Field in WordPress
- Display All Top Child Categories / Taxonomy
- how to get custom attachment url?
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- Get posts by similar names and categories
- Calculating efficiently on large amount of data generated by wp_query
- WP Query issue for multiple values
- Return on a quest all these meta_value
- Complicated WP_Query
- Filter WP_Query output before it is accessed (pre_get_posts)?
- Divide WP_Query posts by date & post type
- Custom query to show posts
- New WordPress WP Query using posts from certain categories
- Edit WordPress loop, taxonomies, & filter
- WP query based on two meta queries
- WordPress website links redirect to homepage
- Is there another way to retrieve a post_id from post_meta other than a SQL query?