WordPress at Your Fingertips
filter is not described

(type)_template filter-hook . WP 1.5.0

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

Usage

add_filter( '(type)_template', 'filter_function_name_8835', 10, 3 );
function filter_function_name_8835( $template, $type, $templates ){
	// filter...

	return $template;
}
$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.

Changelog

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

Where the hook is called

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

Where in WP core the hook is used WordPress

wp-includes/blocks/post-template.php 88
add_action( 'init', 'register_block_core_post_template' );
wp-includes/class-wp-customize-manager.php 676
add_filter( 'template', array( $this, 'get_template' ) );
wp-includes/class-wp-customize-manager.php 682
add_filter( 'pre_option_template', array( $this, 'get_template' ) );
wp-includes/class-wp-customize-manager.php 714
remove_filter( 'template', array( $this, 'get_template' ) );
wp-includes/class-wp-customize-manager.php 720
remove_filter( 'pre_option_template', array( $this, 'get_template' ) );
wp-includes/class-wp-customize-nav-menus.php 65
add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
wp-includes/customize/class-wp-customize-header-image-control.php 107
add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_header_image_template' ) );