Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Show what template file i viewing

Display the path of the template file

function s9_admin_bar_init() {
	// If not an admin or if admin bar isn't showing, do nothing
	if (!is_super_admin() || !is_admin_bar_showing() )
		return;
 
	add_action('admin_bar_menu', 's9_admin_bar_links', 500);
}

add_action('admin_bar_init', 's9_admin_bar_init');

function s9_admin_bar_links() {
	global $wp_admin_bar, $template;
	
	// clean up path
	$template_name = substr( $template, ( strpos( $template, 'wp-content/') + 10 ) );
	
	// Add as a parent menu
	$wp_admin_bar->add_menu( array(
		'title' => $template_name,
		'href' => false,
		'id' => 's9_links',
		'href' => false
	));
}