Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the polylang domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/vajnabot/public_html/wp-includes/functions.php on line 6121
Vajna Botond | Online portofolio | Show which template is used

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.