Show template file name in wordpress
Created at 18-Mar-2021 ,
By samar
Show template file name in wordpress
In this article, we will see how to solve "Show template file name in wordpress".
-
--PATH wp-content\themes\<yourTheme>\functions.php
add_action('wp_head', 'show_template'); function show_template() { global $template; echo basename($template); }
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); ?>
You can just use it directly in the template file (footer.php or header.php) at any place to view your template file name.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Wordpress
- Replace Live Site Url with Local Site URL in wordpress database
- Add new class to body tag in wordpress
- Remove class from body tag in wordpress
- Function to get the post id in while (have_posts()) : the_post();
- How to display author avatar in Wordpress 5
- Remove every class and ID from the wp_nav_menu
- How to use shop in product category and product permalink in woocommerce
- Create shortcode in wordpress functions php
- Custom post type in wordpress
- Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/xxx/public_html/wp-includes/plugin.php on line xxx
- Create a accordion plugin in wordpress
- How to hide PHP Warnings and Notices in WordPress?