WP HOOKS
filtrdynamicznyod 4.7.0

rest_{$this->post_type}_collection_params

Args 2Plik wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

Opis — z kodu źródłowego

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.

Parametry

ParametrTypOpis
$query_paramsarrayJSON Schema-formatted collection parameters.
$post_type\WP_Post_TypePost type object.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_{$this->post_type}_collection_params', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii