danielhq
2/6/2015 - 11:42 AM

Wordpress current template

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'];
}