filtrdynamicznyod 3.9.0
theme_{$post_type}_templates
Args 4Plik wp-includes/class-wp-theme.php
Opis — z kodu źródłowego
Filters list of page templates for a theme.
The dynamic portion of the hook name, $post_type, refers to the post type.
Possible hook names include:
theme_post_templatestheme_page_templatestheme_attachment_templates
Hook dynamiczny — możliwe nazwy
theme_attachment_templatestheme_page_templatestheme_post_templatesParametry
| Parametr | Typ | Opis |
|---|---|---|
$post_templates | string[] | Array of template header names keyed by the template file name. |
$theme | \WP_Theme | The theme object. |
$post | \WP_Post | null | The post being edited, provided for context, or null. |
$post_type | string | Post type to get the templates for. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'theme_{$post_type}_templates', 'twoja_funkcja', 10, 4 );
function twoja_funkcja($param_1, $param_2, $param_3, $param_4) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'theme_{$post_type}_templates', 'twoja_funkcja', 10, 4 );
function twoja_funkcja($param_1, $param_2, $param_3, $param_4) {
// Twój kod
}Popularne w tej kategorii