Skip to content

Instantly share code, notes, and snippets.

@leemcd56
Created May 21, 2018 13:52
Show Gist options
  • Save leemcd56/5e87fc1eca2f94fa009a691918974243 to your computer and use it in GitHub Desktop.
Save leemcd56/5e87fc1eca2f94fa009a691918974243 to your computer and use it in GitHub Desktop.
Current template in Wordpress admin bar
<?php
// Trouble knowing the current template?
add_action('admin_bar_menu', function ($adminBar) {
global $template;
$templateName = basename($template);
$adminBar->add_menu([
'id' => 'template-name',
'parent' => 'top-secondary',
'title' => 'Template: ' . $templateName,
'href' => '#',
'meta' => [
'title' => __('Template name')
]
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment