Title: pre_get_comments
Published: April 25, 2014
Last modified: August 20, 2026

---

# do_action_ref_array( ‘pre_get_comments’, WP_Comment_Query $query )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#changelog)

Fires before comments are retrieved.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#parameters)󠁿

 `$query`[WP_Comment_Query](https://developer.wordpress.org/reference/classes/wp_comment_query/)

Current instance of [WP_Comment_Query](https://developer.wordpress.org/reference/classes/wp_comment_query/)(
passed by reference).

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#source)󠁿

    ```php
    do_action_ref_array( 'pre_get_comments', array( &$this ) );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-comment-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-comment-query.php#L401)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-comment-query.php#L401-L401)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Comment_Query::get_comments()](https://developer.wordpress.org/reference/classes/wp_comment_query/get_comments/)`wp-includes/class-wp-comment-query.php` |

Get a list of comments matching the query vars.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/pre_get_comments/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpre_get_comments%2F)
before being able to contribute a note or feedback.