is_post_publicly_viewable()

最后更新于:2021-11-27 10:04:05

is_post_publicly_viewable( int|GC_Post|null$post=null)

Determine whether a post is publicly viewable.

参数

$post

(int|GC_Post|null) (Optional) Post ID or post object. Defaults to global $post.

Default value: null

响应

(bool) Whether the post is publicly viewable.

源文件

文件: gc-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 );
}