Vajna Botond

Designer

Show which template is used

Sometimes when we want to know what template a page uses, specially when working with themes that we are not used to it.

The following script will show the path to the current template in the footer if admin user is logged in, paste it in functions.php

// show which template is used
function meks_which_template_is_loaded() {
   if ( is_super_admin() ) {
       global $template;
       print_r( $template );
   }
}
add_action( 'wp_footer', 'meks_which_template_is_loaded' );

As you can see, it is hooked to WP_footer, if you are not using this hook, than paste it in the footer without the hook like this:

if ( is_super_admin() ) {
       global $template;
       print_r( $template );
   }

Note: if you are using multiple footers, you have to insert it in all, otherwise it will show only on pages that are using that footer.

Alternatively you can past in also in the header, or anywhere else you like, in a module that appears anywhere in the site.