函数原型
get_post_type_archive_template(): string
函数描述
Retrieves path of post type archive template in current or parent template.
是否弃用
未弃用
函数参数
无
函数返回值
string Full path to archive template file.
函数位置
File: wp-includes/template.php.
函数源码
function get_post_type_archive_template() {
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) ) {
$post_type = reset( $post_type );
}
$obj = get_post_type_object( $post_type );
if ( ! ( $obj instanceof WP_Post_Type ) || ! $obj->has_archive ) {
return '';
}
return get_archive_template();
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |

