Detect which WordPress template is being used
In header.php, is there some way to detect and alert which template is displaying the current page? For example, I attempted something like:
<script type="text/javascript">
alert("<?php echo is_page_template(); ?>");
</script>
I would prefer an answer that doesn'开发者_运维知识库t require me to explicitly state and test each filename in that alert. But, even when I did put in a template file's name, it alerted blank rather than true or false. Any ideas?
You can do the following:
get_post_meta($post->ID,'_wp_page_template',true);
精彩评论