<type>_template

Filters the path of the queried template by type.

Description

apply_filters( '<type>_template', (string) $template ); 

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.
  1. $template = apply_filters( '{$type}_template', $template ); 
  2.  
  3. if ( !empty( $template ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the <type>_template callback 
  2. function filter_type_template( $template ) { 
  3. // make filter magic happen here... 
  4. return $template
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "{$type}_template", 'filter_type_template', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "{$type}_template", 'filter_type_template', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/template.php  
  1. return apply_filters( "{$type}_template", $template );