filtrdynamicznyod 4.7.0
rest_prepare_{$this->post_type}
Args 3Plik wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
Opis — z kodu źródłowego
Filters the post data for a REST API response.
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
rest_prepare_postrest_prepare_pagerest_prepare_attachment
Hook dynamiczny — możliwe nazwy
rest_prepare_attachmentrest_prepare_pagerest_prepare_postParametry
| Parametr | Typ | Opis |
|---|---|---|
$response | \WP_REST_Response | The response object. |
$post | \WP_Post | Post object. |
$request | \WP_REST_Request | Request object. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_prepare_{$this->post_type}', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_prepare_{$this->post_type}', 'twoja_funkcja', 10, 3 );
function twoja_funkcja($param_1, $param_2, $param_3) {
// Twój kod
}Popularne w tej kategorii