函数原型
is_page_template( string|string[] $template = ” ): bool
函数描述
Determines whether the current post uses a page template.
是否弃用
未弃用
函数参数
-
$template
string|string[]
Optional - The specific template filename or array of templates to match.
Default:
''
函数返回值
bool True on success, false on failure.
函数位置
File: wp-includes/post-template.php.
函数源码
is_page_template( 'templates/about.php' );源码链接
变更日志
| Version | Description |
|---|---|
| 4.7.0 | Now works with any post type, not just pages. |
| 4.2.0 | The $template parameter was changed to also accept an array of page templates. |
| 2.5.0 | Introduced. |

