Show current WordPress template

The WordPress template hierarchy is complex to say the least, or at least, not overly memorable…

It’s incredibly useful and powerful to be able to create overriding custom templates, giving you full control over what you want to display for different parts of the WordPress site you’re creating.

However, it’s easy to get lost, and not be sure which template is currently showing.  And for this, this tiny little snippet can be incredibly helpful for debugging..

function show_template() {
  global $template;
add_action('wp_head', 'show_template');

Alternatively, you can use the Show Current Template plugin, which is one of my gotos when building custom templates, like I did for London Art WeekMaster Drawings New York and this website itself.

As you can see above, this displays the current template file in the admin bar, with a dropdown of additional information, such as included template files – very handy!

P.S. In the screenshot you can also see my dark theme in use, if you haven’t tried it yourself yet, and I’m beta testing my own Better Security Pro plugin which is coming soon.