描述:
判断某个文章类型是否存在
用法:
<?php post_type_exists( $post_type ); ?>
参数:
$post_type
(string) (必填) 自定义文章类型
默认值: None
示例:
if ( post_type_exists( 'book' ) ) {
echo 'the Book post type exists';
}
源文件:
/**
* Check if a post type is registered.
*
* @since 3.0.0
*
* @see get_post_type_object()
*
* @param string $post_type Post type name.
* @return bool Whether post type is registered.
*/
function post_type_exists( $post_type ) {
return (bool) get_post_type_object( $post_type );
}