rest_{$this->post_type}_collection_params WordPress Filter Hook

The rest_{$this->post_type}_collection_params hook allows you to modify the parameters that are used to query the collection of posts for a given post type. This can be useful for limiting the number of posts that are returned, or for ordering the posts in a specific way.

apply_filters( "rest_{$this->post_type}_collection_params", array $query_params, WP_Post_Type $post_type ) #

Filters collection parameters for the posts controller.


Description

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.


Top ↑

Parameters

$query_params

(array)JSON Schema-formatted collection parameters.

$post_type

(WP_Post_Type)Post type object.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.