is_post_type_viewable filter-hookWP 5.9.0

Filters whether a post type is considered "viewable".

The returned filtered value must be a boolean type to ensure is_post_type_viewable() 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.


add_filter( 'is_post_type_viewable', 'wp_kama_is_post_type_viewable_filter', 10, 2 );

 * Function for `is_post_type_viewable` filter-hook.
 * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
 * @param WP_Post_Type $post_type   Post type object.
 * @return bool
function wp_kama_is_post_type_viewable_filter( $is_viewable, $post_type ){

	// filter...
	return $is_viewable;
Whether the post type is "viewable" (strict type).
Post type object.


Since 5.9.0 Introduced.

Where the hook is called

wp-includes/post.php 2378
return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type );

Where the hook is used in WordPress

Usage not found.