post_type_exists

Check if a post type is registered.

Description

post_type_exists( (string) $post_type ); 

Parameters (1)

0. $post_type (string)
Post type name.

Usage

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

Defined (1)

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

/wp-includes/post.php  
  1. function post_type_exists( $post_type ) { 
  2. return (bool) get_post_type_object( $post_type );