rest_(post_type)_query хук-фильтрWP 4.7.0

Filters WP_Query arguments when querying posts via the REST API.

The dynamic portion of the hook name, $this->post_type, refers to the post type slug.

Possible hook names include:

Enables adding extra arguments or setting defaults for a post collection request.


add_filter( 'rest_(post_type)_query', 'wp_kama_rest_post_type_query_filter', 10, 2 );

 * Function for `rest_(post_type)_query` filter-hook.
 * @param array           $args    Array of arguments for WP_Query.
 * @param WP_REST_Request $request The REST API request.
 * @return array
function wp_kama_rest_post_type_query_filter( $args, $request ){

	// filter...
	return $args;
Array of arguments for WP_Query.
The REST API request.

Список изменений

С версии 4.7.0 Введена.
С версии 5.7.0 Moved after the tax_query query arg is generated.

Где вызывается хук

wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 359
$args       = apply_filters( "rest_{$this->post_type}_query", $args, $request );

Где используется хук в WordPress

Использование не найдено.