函数原型
is_post_publicly_viewable( int|WP_Post|null $post = null ): bool
函数描述
Determines whether a post is publicly viewable.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post|null
Optional - Post ID or post object. Defaults to global $post.
Default:
null
函数返回值
bool Whether the post is publicly viewable.
函数位置
File: wp-includes/post.php.
函数源码
function is_post_publicly_viewable( $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$post_type = get_post_type( $post );
$post_status = get_post_status( $post );
return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |

