Show template file name in wordpress

Answers 2
  • --PATH wp-content\themes\<yourTheme>\functions.php
    add_action('wp_head', 'show_template');
    function show_template() {
        global $template;
        echo basename($template);
    }
    
    0
    If you want to know your current working template file name in wordpress you can see it using this code snippet. Just copy paste this code snippet in your functions.php, it will display the current working template file name. Using this code snippet you can know which template file in your theme is actually being used on a specific page.
  • --PATH wp-content\themes\<yourTheme>\footer.php
    <?php global $template; echo basename($template); ?>
    
    0
    You can just use it directly in the template file (footer.php or header.php) at any place to view your template file name.
  • Back to code snippet queries related wordpress