WP_REST_Posts_Controller::get_collection_params(): array
- Since
- 4.7.0, 5.4.0, 5.7.0
- Source
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:2974
Retrieves the query params for the posts collection.
Return
array- Collection parameters.
Hooks fired · 1
One hook fires while WP_REST_Posts_Controller::get_collection_params() runs, in this order:
- apply_filters( rest_{$this->post_type}_collection_params )filterline 3179 (+205 into the body)
Filters collection parameters for the posts controller.
Uses · 8
- __()Retrieves the translation of $text.
- post_type_supports()Checks a post type's support for a given feature.
- get_post_type_object()Retrieves a post type object by name.
- get_post_stati()Gets a list of post statuses.
- get_post_format_slugs()Retrieves the array of post format slugs.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- WP_REST_Controller::get_collection_params()Retrieves the query params for the collections.
- WP_REST_Posts_Controller::prepare_taxonomy_limit_schema()Prepares the collection schema for including and excluding items by terms.
Used by · 6
- WP_REST_Attachments_Controller::get_collection_params()Retrieves the query params for collections of attachments.
- WP_REST_Font_Faces_Controller::get_collection_params()Retrieves the query params for the font face collection.
- WP_REST_Font_Families_Controller::get_collection_params()Retrieves the query params for the font family collection.
- WP_REST_Menu_Items_Controller::get_collection_params()Retrieves the query params for the nav menu items collection.
- WP_REST_Posts_Controller::get_items()Retrieves a collection of posts.
- WP_REST_Posts_Controller::register_routes()Registers the routes for posts.
Source
public function get_collection_params() { $query_params = parent::get_collection_params(); $query_params['context']['default'] = 'view'; $query_params['after'] = array( 'description' => __( 'Limit response to posts published after a given ISO8601 compliant date.' ), 'type' => 'string', 'format' => 'date-time', ); $query_params['modified_after'] = array( 'description' => __( 'Limit response to posts modified after a given ISO8601 compliant date.' ), 'type' => 'string', 'format' => 'date-time', ); if ( post_type_supports( $this->post_type, 'author' ) ) { $query_params['author'] = array( 'description' => __( 'Limit result set to posts assigned to specific authors.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), 'default' => array(), ); $query_params['author_exclude'] = array( 'description' => __( 'Ensure result set excludes posts assigned to specific authors.' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), 'default' => array(), ); } $query_params['before'] = array( 'description' => __( 'Limit response to posts published before a given ISO8601 compliant date.' ), 'type' => 'string', 'format' => 'date-time', ); $query_params['modified_before'] = array( 'description' => __( 'Limit response to posts modified 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(), ); if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) { $query_params['menu_order'] = array( 'description' => __( 'Limit result set to posts with a specific menu_order value.' ), 'type' => 'integer', ); } $query_params['search_semantics'] = array( 'description' => __( 'How to interpret the search input.' ), 'type' => 'string', 'enum' => array( 'exact' ), ); $query_params['offset'] = array(History
Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.7.0
The
modified_after and modified_before query parameters were added.from the docblock5.4.0
The
tax_relation query parameter was added.from the docblock4.7.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.