确定是否已注册帖子类型。
原型
post_type_exists( string $post_type )
描述
有关此功能和类似主题功能的更多信息,请查看Theme Developer Handbook中的Conditional Tags文章。
参考:
- get_post_type_object()
参数
$post_type
(string)
(Required)
发布类型名称。
返回值
(bool)
是否注册了帖子类型。
源文件
路径:wp-includes/post.php
<?php
...
function post_type_exists( $post_type ) {
return (bool) get_post_type_object( $post_type );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/post_type_exists/