Determine Which WordPress Template Is Used

In header.php, is there a way to detect and notify which template displays the current page? For example, I tried something like:

<script type="text/javascript"> alert("<?php echo is_page_template(); ?>"); </script> 

I would prefer an answer that does not require me to explicitly state and test each file name in this warning. But even when I entered the name of the template file, it warned empty, not true or false. Any ideas?

+4
source share
1 answer

You can do the following:

 get_post_meta($post->ID,'_wp_page_template',true); 
+3
source

Source: https://habr.com/ru/post/1313893/


All Articles