How to find which WordPress template file is serving on the current page
Home » BLOG » WordPress » How to find which WordPress template file is serving on the current page

How to find which WordPress template file is serving on the current page

category:  WordPress

As a WordPress developer, you often want to know which template is serving the page you want so that you can customize that template. I see so many methods over the internet but I like this method because it is quick.

Here is the code that you will add to the functions.php on your active theme.

function show_template() {
    if( is_admin() ){
        global $template;
        print_r($template);
    } 
}
add_action('wp_footer', 'show_template');

We check if the login user is the admin, and we will show the current template at the footer. DON’T forget to remove it after you are done with developing.

This code I found this from this link. I think it is useful for sharing in my post.