<type>_template
Filters the path of the queried template by type.
Description
The dynamic portion(s) of the hook name refer 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 values for $type
include: index,, 404., archive, author, category, tag, taxonomy, date, 'embed', home', frontpage, page, paged, search, single, singular, and attachment.
Parameters (1)
- 0. $template (string)
- Path to the template. See
locate_template(…)
.
Usage
- To run the hook, copy the example below.
- $template = apply_filters( '{$type}_template', $template );
- if ( !empty( $template ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the <type>_template callback
- function filter_type_template( $template ) {
- // make filter magic happen here...
- return $template;
- };
- // add the filter
- add_filter( "{$type}_template", 'filter_type_template', 10, 1 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( "{$type}_template", 'filter_type_template', 10, 1 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/template.php
- return apply_filters( "{$type}_template", $template );