rest_(post_type)_collection_params
Filter collection parameters for the posts controller.
The dynamic part of the filter $this->post_type refers to the post type slug for the controller.
This filter registers the collection parameter, but does not map the collection parameter to an internal WP_Query parameter. Use the rest_{$this->post_type}_query filter to set WP_Query parameters.
Usage
add_filter( 'rest_(post_type)_collection_params', 'wp_kama_rest_post_type_collection_params_filter', 10, 2 );
/**
* Function for `rest_(post_type)_collection_params` filter-hook.
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @param WP_Post_Type $post_type Post type object.
*
* @return array
*/
function wp_kama_rest_post_type_collection_params_filter( $query_params, $post_type ){
// filter...
return $query_params;
}
- $query_params(array)
- JSON Schema-formatted collection parameters.
- $post_type(WP_Post_Type)
- Post type object.
Where the hook is called
rest_(post_type)_collection_params
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php 706
return apply_filters( "rest_{$this->post_type}_collection_params", $params, $this->post_type );
Where the hook is used in WooCommerce
woocommerce/includes/class-wc-brands.php 72
add_filter( 'rest_product_collection_params', array( $this, 'rest_api_product_collection_params' ), 10, 2 );
woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php 80
add_filter( 'rest_product_collection_params', array( $this, 'extend_rest_query_allowed_params' ), 10, 1 );
woocommerce/src/Blocks/BlockTypes/ProductQuery.php 86
add_filter( 'rest_product_collection_params', array( $this, 'extend_rest_query_allowed_params' ), 10, 1 );