filtrdynamicznyod 4.7.0
rest_{$this->post_type}_query
Args 2Plik wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Opis — z kodu źródłowego
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:
rest_post_queryrest_page_queryrest_attachment_queryEnables adding extra arguments or setting defaults for a post collection request.
Hook dynamiczny — możliwe nazwy
rest_attachment_queryrest_page_queryrest_post_queryParametry
| Parametr | Typ | Opis |
|---|---|---|
$args | array | Array of arguments for WP_Query. |
$request | \WP_REST_Request | The REST API request. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_{$this->post_type}_query', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_{$this->post_type}_query', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}Popularne w tej kategorii