WP HOOKS
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_templates
  • theme_page_templates
  • theme_attachment_templates

Hook dynamiczny — możliwe nazwy

theme_attachment_templatestheme_page_templatestheme_post_templates

Parametry

ParametrTypOpis
$post_templatesstring[]Array of template header names keyed by the template file name.
$theme\WP_ThemeThe theme object.
$post\WP_Post | nullThe post being edited, provided for context, or null.
$post_typestringPost 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
}

Popularne w tej kategorii