is_post_type_viewable

Determines whether a post type is considered "viewable".

Description

is_post_type_viewable( (string|WP_Post_Type) $post_type ); 

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.

Parameters (1)

0. $post_type (string|WP_Post_Type)
Post type name or object.

Usage

  1. if ( !function_exists( 'is_post_type_viewable' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // Post type name or object. 
  5. $post_type = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_post_type_viewable($post_type); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function is_post_type_viewable( $post_type ) { 
  2. if ( is_scalar( $post_type ) ) { 
  3. $post_type = get_post_type_object( $post_type ); 
  4. if ( ! $post_type ) { 
  5. return false; 
  6.  
  7. return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );