Skip to content

Instantly share code, notes, and snippets.

@danyeah
Last active August 29, 2015 14:14
Show Gist options
  • Save danyeah/ced1075bfc098fcca581 to your computer and use it in GitHub Desktop.
Save danyeah/ced1075bfc098fcca581 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