is_post_type_viewable

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

WordPress Version: 5.9

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 5.7

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: 6.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .10

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 5.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .11

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 4.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .12

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 3.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .14

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 2.3

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .20

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 2.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .17

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 1.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .15

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 5.1

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: 0.3

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .20

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 0.2

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .18

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 9.3

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: .22

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    if (!is_object($post_type)) {
        return false;
    }
    $is_viewable = $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
    /**
     * Filters whether a post type is considered "viewable".
     *
     * The returned filtered value must be a boolean type to ensure
     * `is_post_type_viewable()` only returns a boolean. This strictness
     * is by design to maintain backwards-compatibility and guard against
     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     * and truthy values) will result in the function returning false.
     *
     * @since 5.9.0
     *
     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     * @param WP_Post_Type $post_type   Post type object.
     */
    return true === apply_filters('is_post_type_viewable', $is_viewable, $post_type);
}

WordPress Version: 4.6

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
 *
 * @param string|WP_Post_Type $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: 4.5

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
 *
 * @param object $post_type Post type name or object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type)
{
    if (is_scalar($post_type)) {
        $post_type = get_post_type_object($post_type);
        if (!$post_type) {
            return false;
        }
    }
    return $post_type->publicly_queryable || $post_type->_builtin && $post_type->public;
}

WordPress Version: 4.4

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 *
 * @param object $post_type_object Post type object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable($post_type_object)
{
    return $post_type_object->publicly_queryable || $post_type_object->_builtin && $post_type_object->public;
}