开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜