is_page_template 判断是否使用了指定的page模板
WordPress 主题可以使用 is_page_template 判断当前 page 使用的模板文件。此函数在实际中的用途,尚未明了……
如果一个模板文件存在,比如 about.php 。那么在 about.php 中 is_page_template('about.php') 必为 true。如果 about.php 不存在,无论在那里判断 is_page_template('about.php') 也是 false ……
也想出现在这里?联系我们吧

能想到的,在一些公共的文件中,比如:header.php、fotter.php 中,有一些用处。
if ( is_page_template( 'about.php' ) ) {
// about.php is used
} else {
// about.php is not used
}
如果模板在目录中,使用函数时,也要带上目录。比如 about.php 在目录 tpl 中,则正确的写法是:is_page_template( 'tpl/about.php' )