{$type}_template WordPress Filter Hook

The {$type}_template hook is used to specify the template file that should be used to render the {$type} page.

apply_filters( "{$type}_template", string $template, string $type, string[] $templates ) #

Filters the path of the queried template by type.


Description

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

Top ↑

Parameters

$template

(string)Path to the template. See locate_template().

$type

(string)Sanitized filename without extension.

$templates

(string[])A list of template candidates, in descending order of priority.


Top ↑

More Information

If you need more granular control over the template selection and loading system of WordPress, consider using template_include instead.


Top ↑

Source

File: wp-includes/template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.8.0The $type and $templates parameters were added.
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.