Skip to content

Instantly share code, notes, and snippets.

@danyeah
Created September 20, 2017 07:56
Show Gist options
  • Save danyeah/58f52c3e41703ccfb8d499b08481746c to your computer and use it in GitHub Desktop.
Save danyeah/58f52c3e41703ccfb8d499b08481746c to your computer and use it in GitHub Desktop.
Wordpress current template
// 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