in Web and Tech, Work

WP Template Identifier

Another WordPress debug script.

This one shows what template the current page is using.

Add this code to functions.php
add_filter( 'template_include', 'var_template_include', 1000 );
function var_template_include( $t ){
$GLOBALS['current_theme_template'] = basename($t);
return $t;
}

Add this code inside header.php or footer.php to display the template file name.

function get_current_template( $echo = false ) {
if( !isset( $GLOBALS['current_theme_template'] ) )
return false;
if( $echo )
echo $GLOBALS['current_theme_template'];
else
return $GLOBALS['current_theme_template'];
}

Write a Comment

Comment