is_post_publicly_viewable

The timeline below displays how wordpress function is_post_publicly_viewable has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Determines whether a post is publicly viewable.
 *
 * Posts are considered publicly viewable if both the post status and post type
 * are viewable.
 *
 * @since 5.7.0
 *
 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
 * @return bool Whether the post is publicly viewable.
 */
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);
}

WordPress Version: 5.7

/**
 * Determine whether a post is publicly viewable.
 *
 * Posts are considered publicly viewable if both the post status and post type
 * are viewable.
 *
 * @since 5.7.0
 *
 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
 * @return bool Whether the post is publicly viewable.
 */
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);
}

WordPress Version: .22

/**
 * Determines whether a post is publicly viewable.
 *
 * Posts are considered publicly viewable if both the post status and post type
 * are viewable.
 *
 * @since 5.7.0
 *
 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
 * @return bool Whether the post is publicly viewable.
 */
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);
}