Created
October 25, 2018 17:20
-
-
Save garek007/3c175591a232a25ce44462f0ba781072 to your computer and use it in GitHub Desktop.
Wordpress get template name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; | |
} | |
//then use this in the header or footer to get file name of template used | |
//<div style="display:none;"><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