How to Find out Which Template WordPress is Using to Display Your Content

If you are a WordPress theme developer you may want to know which template WordPress is using to display your content. Today we are sharing a little snippet that you can use to display the name of the current template in the the admin bar.
[php]

add_action( ‘wp_head’, ‘display_current_template’ );

function display_current_template() {
global $template, $current_user, $wp_admin_bar;

get_currentuserinfo();

if ( !is_user_logged_in() && $current_user->ID != ‘1’ )
return;
if ( is_admin_bar_showing() )
$wp_admin_bar->add_menu( array(
‘parent’ => false,
‘id’ => ‘template’,
‘title’ => $template,
‘href’ => ‘#’
));
else
print_r( $template );
}

[/php]