检测WordPress当前页面使用的哪个模板文件的方法
在制作WordPress主题的时候,有时候需要知道建好的模板是否生效,或者想知道当前页面置于哪个模板文件内,那么该怎么查找这个页面是利用的哪个模板文件呢?
方法①:
1.查找wordpress源文件:wp-includes\template-loader.php, 找到以下代码:
else : $template = get_index_template(); endif;
2.在其下面添加以下代码:
if($_GET[tpl]=='die'){
die($template);
}
在需要查看模板路径的页面都输入?tpl=die,如http://localhost/wordpress/?tpl=die
方法②:
使用一个叫“Show Current Template”的插件。
