Skip to content

Instantly share code, notes, and snippets.

@LeahArmstrong
Created June 11, 2013 21:55
Show Gist options
  • Save LeahArmstrong/5761088 to your computer and use it in GitHub Desktop.
Save LeahArmstrong/5761088 to your computer and use it in GitHub Desktop.
Reveal current page template being used by Wordpress
/* Generates current template file name - For debugging only! */
add_filter( 'template_include', 'var_template_include', 1000 );
function var_template_include( $t ){
$GLOBALS['current_theme_template'] = basename($t);
return $t;
}
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'];
}
<div><strong>Current template:</strong> <?php get_current_template( true ); ?></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment