Title: WP_REST_Comments_Controller::get_collection_params
Published: December 6, 2016
Last modified: May 20, 2026

---

# WP_REST_Comments_Controller::get_collection_params(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#wp--skip-link--target)

Retrieves the query params for collections.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#return)󠁿

 array Comments collection parameters.

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

    ```php
    public function get_collection_params() {
    	$query_params = parent::get_collection_params();

    	$query_params['context']['default'] = 'view';

    	$query_params['after'] = array(
    		'description' => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
    		'type'        => 'string',
    		'format'      => 'date-time',
    	);

    	$query_params['author'] = array(
    		'description' => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    	);

    	$query_params['author_exclude'] = array(
    		'description' => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    	);

    	$query_params['author_email'] = array(
    		'default'     => null,
    		'description' => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
    		'format'      => 'email',
    		'type'        => 'string',
    	);

    	$query_params['before'] = array(
    		'description' => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
    		'type'        => 'string',
    		'format'      => 'date-time',
    	);

    	$query_params['exclude'] = array(
    		'description' => __( 'Ensure result set excludes specific IDs.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    		'default'     => array(),
    	);

    	$query_params['include'] = array(
    		'description' => __( 'Limit result set to specific IDs.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    		'default'     => array(),
    	);

    	$query_params['offset'] = array(
    		'description' => __( 'Offset the result set by a specific number of items.' ),
    		'type'        => 'integer',
    	);

    	$query_params['order'] = array(
    		'description' => __( 'Order sort attribute ascending or descending.' ),
    		'type'        => 'string',
    		'default'     => 'desc',
    		'enum'        => array(
    			'asc',
    			'desc',
    		),
    	);

    	$query_params['orderby'] = array(
    		'description' => __( 'Sort collection by comment attribute.' ),
    		'type'        => 'string',
    		'default'     => 'date_gmt',
    		'enum'        => array(
    			'date',
    			'date_gmt',
    			'id',
    			'include',
    			'post',
    			'parent',
    			'type',
    		),
    	);

    	$query_params['parent'] = array(
    		'default'     => array(),
    		'description' => __( 'Limit result set to comments of specific parent IDs.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    	);

    	$query_params['parent_exclude'] = array(
    		'default'     => array(),
    		'description' => __( 'Ensure result set excludes specific parent IDs.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    	);

    	$query_params['post'] = array(
    		'default'     => array(),
    		'description' => __( 'Limit result set to comments assigned to specific post IDs.' ),
    		'type'        => 'array',
    		'items'       => array(
    			'type' => 'integer',
    		),
    	);

    	$query_params['status'] = array(
    		'default'           => 'approve',
    		'description'       => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
    		'sanitize_callback' => 'sanitize_key',
    		'type'              => 'string',
    		'validate_callback' => 'rest_validate_request_arg',
    	);

    	$query_params['type'] = array(
    		'default'           => 'comment',
    		'description'       => __( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
    		'sanitize_callback' => 'sanitize_key',
    		'type'              => 'string',
    		'validate_callback' => 'rest_validate_request_arg',
    	);

    	$query_params['password'] = array(
    		'description' => __( 'The password for the post if it is password protected.' ),
    		'type'        => 'string',
    	);

    	/**
    	 * Filters REST API collection parameters for the comments controller.
    	 *
    	 * This filter registers the collection parameter, but does not map the
    	 * collection parameter to an internal WP_Comment_Query parameter. Use the
    	 * `rest_comment_query` filter to set WP_Comment_Query parameters.
    	 *
    	 * @since 4.7.0
    	 *
    	 * @param array $query_params JSON Schema-formatted collection parameters.
    	 */
    	return apply_filters( 'rest_comment_collection_params', $query_params );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1663)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1663-L1811)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#hooks)󠁿

 [apply_filters( ‘rest_comment_collection_params’, array $query_params )](https://developer.wordpress.org/reference/hooks/rest_comment_collection_params/)

Filters REST API collection parameters for the comments controller.

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

| Uses | Description | 
| [WP_REST_Controller::get_collection_params()](https://developer.wordpress.org/reference/classes/wp_rest_controller/get_collection_params/)`wp-includes/rest-api/endpoints/class-wp-rest-controller.php` |

Retrieves the query params for the collections.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_collection_params/?output_format=md#)

| Used by | Description | 
| [WP_REST_Comments_Controller::register_routes()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/register_routes/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Registers the routes for comments.

  | 
| [WP_REST_Comments_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Retrieves a list of comment items.

  |

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

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

## User Contributed Notes

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