Filter hook 'template_include'

in WP Core File wp-includes/template-loader.php at line 104

View Source

template_include

Filter Hook
Description
Filters the path of the current template before including it.

Hook Information

File Location wp-includes/template-loader.php View on GitHub
Hook Type Filter
Line Number 104

Hook Parameters

Type Name Description
string $template The path of the template to include.

Usage Examples

Basic Usage
<?php
// Hook into template_include
add_filter('template_include', 'my_custom_filter', 10, 1);

function my_custom_filter($template) {
    // Your custom filtering logic here
    return $template;
}

Source Code Context

wp-includes/template-loader.php:104 - How this hook is used in WordPress core
<?php
  99  	 *
 100  	 * @since 3.0.0
 101  	 *
 102  	 * @param string $template The path of the template to include.
 103  	 */
 104  	$template = apply_filters( 'template_include', $template );
 105  	if ( $template ) {
 106  		include $template;
 107  	} elseif ( current_user_can( 'switch_themes' ) ) {
 108  		$theme = wp_get_theme();
 109  		if ( $theme->errors() ) {

PHP Documentation

<?php
/**
	 * Filters the path of the current template before including it.
	 *
	 * @since 3.0.0
	 *
	 * @param string $template The path of the template to include.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/template-loader.php
Related Hooks

Related hooks will be displayed here in future updates.