rest_<taxonomy>_collection_params

Filter collection parameters for the terms controller.

Description

apply_filters( 'rest_<taxonomy>_collection_params', (array) $query_params, (WP_Taxonomy) $taxonomy ); 

The dynamic part of the filter $this->taxonomy refers to the taxonomy slug for the controller.

This filter registers the collection parameter, but does not map the collection parameter to an internal WP_Term_Query parameter. Use the 'rest__query' filter to set WP_Term_Query parameters.

Parameters (2)

0. $query_params (array)
JSON Schema-formatted collection parameters.
1. $taxonomy (WP_Taxonomy)
Taxonomy object.

Usage

To run the hook, copy the example below.
  1. $query_params = apply_filters( 'rest_{$taxonomy}_collection_params', $query_params, $taxonomy ); 
  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_<taxonomy>_collection_params callback 
  2. function filter_rest_taxonomy_collection_params( $query_params, $taxonomy ) { 
  3. // make filter magic happen here... 
  4. return $query_params
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "rest_{$taxonomy}_collection_params", 'filter_rest_taxonomy_collection_params', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "rest_{$taxonomy}_collection_params", 'filter_rest_taxonomy_collection_params', 10, 2 ); 

Defined (1)

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

/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php  
  1. return apply_filters( "rest_{$this->taxonomy}_collection_params", $query_params, $taxonomy );