is_post_type_viewable WordPress Filter Hook

The is_post_type_viewable WordPress hook allows custom post types to be viewed by the public. This hook is useful for custom post types that need to be visible to the public, but not necessarily editable by them. By default, custom post types are not viewable by the public.

apply_filters( 'is_post_type_viewable', bool $is_viewable, WP_Post_Type $post_type ) #

Filters whether a post type is considered “viewable”.


Description

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.


Top ↑

Parameters

$is_viewable

(bool)Whether the post type is "viewable" (strict type).

$post_type

(WP_Post_Type)Post type object.


Top ↑

Source

File: wp-includes/post.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More