WP HOOKS
filtrdynamicznyod 1.5.0

{$type}_template

Args 3Plik wp-includes/template.php

Opis — z kodu źródłowego

Filters the path of the queried template by type.

The dynamic portion of the hook name, $type, refers to the filename -- minus the file extension and any non-alphanumeric characters delimiting words -- of the file to load. This hook also applies to various types of files loaded as part of the Template Hierarchy. Possible hook names include:

  • 404_template
  • archive_template
  • attachment_template
  • author_template
  • category_template
  • date_template
  • embed_template
  • frontpage_template
  • home_template
  • index_template
  • page_template
  • paged_template
  • privacypolicy_template
  • search_template
  • single_template
  • singular_template
  • tag_template
  • taxonomy_template

Hook dynamiczny — możliwe nazwy

404_templatearchive_templateattachment_templateauthor_templatecategory_templatedate_templateembed_templatefrontpage_templatehome_templateindex_templatepage_templatepaged_templateprivacypolicy_templatesearch_templatesingle_templatesingular_templatetag_templatetaxonomy_template

Parametry

ParametrTypOpis
$templatestringPath to the template. See locate_template().
$typestringSanitized filename without extension.
$templatesstring[]A list of template candidates, in descending order of priority.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( '{$type}_template', 'twoja_funkcja', 10, 3 );

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

Popularne w tej kategorii