Created
September 20, 2017 07:56
-
-
Save danyeah/58f52c3e41703ccfb8d499b08481746c to your computer and use it in GitHub Desktop.
Wordpress current template
This file contains 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
// Outputs the template used | |
// Usage: echo get_current_template(true); | |
// Credits: http://www.kevinleary.net/get-current-theme-template-filename-wordpress/ | |
function define_current_template( $template ) { | |
$GLOBALS['current_theme_template'] = basename($template); | |
return $template; | |
} | |
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']; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment