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
- Child Comments not showing in `wp_comment_query`
- 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
- WordPress Meta Query Null Values Order
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- WP Query by variable custom field
- How sort products by calculate value? ( custom post meta, price, option)
- wc_get_products() return empty object
- Multiple meta_query not returning rows
- How can I filter products by meta in Woocommerce REST API?
- WP_Query multiple value not working
- show related articles in single.php template
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- meta_query order by date present -> future then show null
- show most viewed post
- WP_Query() not filtering posts for category
- How do I stop the same post showing multiple times in a archive?
- posts_per_page not working in block
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- How to check if logged in user have pending custom post?
- WP_Query Regexp whitespace and end of string
- Change normal grids to masonry grids
- Custom order of posts in wp_query and different taxonomies
- order posts by a secondary query that counts items
- Get posts that match defined arrays of tags
- wp_query with meta_query and tax_query
- WordPress live search and filter custom fields
- Pass post ID to JavaScript outside the loop
- WordPress live search and filter
- Query for current post
- How to use wp query in my custom page without including header and footer in wordpress
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Slick slider for post doesn’t display anything
- Display posts from multiple value in meta separated by comma
- Access queried post ID in WP_Query
- WooCommerce. How To Exclude Subcategory Products From Category Listing Page
- WP_Query random ordering not working since 5.4
- What is the equivalent WP_Query of a SQL Query?
- IF ( ! $loop->have_posts() ) condition doesn’t work – WP_Query
- create custom shortcode wp and put php code in
- WordPress Query custom ordering by temporary variable
- Check the stored / cached WP_Query with transients on post change
- New template file does not load category-specific post
- Show a message if there are no active posts in category
- Where is the coding error for the unexpected ‘}’ in this if / else choice of loops?
- get_posts return only first result
- Get authors list and sort them by recent posts
- Show custom content when loop or wp query reaches specific time?
- WordPress Query by Category using Post Slug
- How can I write a WP_Query that is this specific?
- How to allow a variable with “/” in wordpress url
- Filter admin ajax data by url query
- Custom filter from post meta
- WordPress custom search form – ignore empty/default input fields upon submission?
- Bootstrap grid while loop
- in_the_loop() issue with custom query
- Related posts queries
- Is there documentation for objects returned by WP_Query?
- Check for not NULL not working in meta query
- order by post date and modified date posts both in wpquery
- Query a database based on form input then output to another page [closed]
- Query for getting posts with their custom fields data in WordPress
- Custom query to retrieve oldest post and retrieve others with date interval
- WP_Query not returning any posts
- Comparing Meta Field date in WPQuery using Meta_Query?
- Pagination unique to a widget
- Ascending numerical sorting with non-numerical characters last
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- WP_Query not returning custom post type
- What code to use in an array to call the current sub-category?
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Custom WordPress post query for displaying time-released content on website
- Get categories within specific term
- Related categories order posts by category
- wp query search multi terms
- WP_Query by MAX post_id?
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- INNER JOIN custom tables – SQL Query