rest_{$this->post_type}_collection_params
Filter HookDescription
Filters 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.Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3109 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$query_params
|
JSON Schema-formatted collection parameters. |
WP_Post_Type
|
$post_type
|
Post type object. |
Usage Examples
Basic Usage
<?php
// Hook into rest_{$this->post_type}_collection_params
add_filter('rest_{$this->post_type}_collection_params', 'my_custom_filter', 10, 2);
function my_custom_filter($query_params, $post_type) {
// Your custom filtering logic here
return $query_params;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:3109
- How this hook is used in WordPress core
<?php
3104 * @since 4.7.0
3105 *
3106 * @param array $query_params JSON Schema-formatted collection parameters.
3107 * @param WP_Post_Type $post_type Post type object.
3108 */
3109 return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );
3110 }
3111
3112 /**
3113 * Sanitizes and validates the list of post statuses, including whether the
3114 * user can query private statuses.
PHP Documentation
<?php
/**
* Filters 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.
*
* @since 4.7.0
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @param WP_Post_Type $post_type Post type object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Related Hooks
Related hooks will be displayed here in future updates.