Skip to content

Instantly share code, notes, and snippets.

@maddisondesigns
Last active April 12, 2023 06:20
Show Gist options
  • Save maddisondesigns/896f1d4c83a6b06a3c3dd51af3dc89d9 to your computer and use it in GitHub Desktop.
Save maddisondesigns/896f1d4c83a6b06a3c3dd51af3dc89d9 to your computer and use it in GitHub Desktop.
Display the name of the current WordPress template being used
<?php
/**
* Debug function to show the name of the current template being used
*/
function mytheme_show_template() {
global $template;
if ( is_user_logged_in() ) {
echo '<div style="background-color:#000;color:#fff;z-index:9999;position:absolute;top:0;">';
print_r( $template );
if ( is_single() ) {
echo ' (and using Post Format: ' . ucfirst( get_post_format() ? get_post_format() : 'standard' ) . ')';
}
echo '</div>';
}
}
add_action( 'wp_head', 'mytheme_show_template' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment