rest_comment_collection_params

Filter collection parameters for the comments controller.

Description

apply_filters( 'rest_comment_collection_params', (array) $query_params ); 

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.

Parameters (1)

0. $query_params (array)
JSON Schema-formatted collection parameters.

Usage

To run the hook, copy the example below.
  1. $query_params = apply_filters( 'rest_comment_collection_params', $query_params ); 
  2.  
  3. if ( !empty( $query_params ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_comment_collection_params callback 
  2. function filter_rest_comment_collection_params( $query_params ) { 
  3. // make filter magic happen here... 
  4. return $query_params
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_comment_collection_params', 'filter_rest_comment_collection_params', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_comment_collection_params', 'filter_rest_comment_collection_params', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php  
  1. return apply_filters( 'rest_comment_collection_params', $query_params );