函数原型
get_page_templates( WP_Post|null $post = null, string $post_type = ‘page’ ): string[]
函数描述
Gets the page templates available in this theme.
是否弃用
未弃用
函数参数
-
$post
WP_Post|null
Optional - The post being edited, provided for context.
Default:
null -
$post_type
string
Optional - Post type to get the templates for. Default
'page'.Default:
'page'
函数返回值
string[] Array of template file names keyed by the template header name.
函数位置
File: wp-admin/includes/theme.php.
函数源码
function get_page_templates( $post = null, $post_type = 'page' ) {
return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.7.0 | Added the $post_type parameter. |
| 1.5.0 | Introduced. |

