Title: post_type_exists
Published: April 25, 2014
Last modified: August 20, 2026

---

# post_type_exists( string $post_type ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#user-contributed-notes)

Determines whether a post type is registered.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#description)󠁿

For more information on this and similar theme functions, check out the [Conditional Tags](https://developer.wordpress.org/themes/basics/conditional-tags/)
article in the Theme Developer Handbook.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#see-also)󠁿

 * [get_post_type_object()](https://developer.wordpress.org/reference/functions/get_post_type_object/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#parameters)󠁿

 `$post_type`stringrequired

Post type name.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#return)󠁿

 bool Whether post type is registered.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#source)󠁿

    ```php
    function post_type_exists( $post_type ) {
    	return (bool) get_post_type_object( $post_type );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/post.php#L1622)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/post.php#L1622-L1624)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#related)󠁿

| Uses | Description | 
| [get_post_type_object()](https://developer.wordpress.org/reference/functions/get_post_type_object/)`wp-includes/post.php` |

Retrieves a post type object by name.

  |

| Used by | Description | 
| [use_block_editor_for_post_type()](https://developer.wordpress.org/reference/functions/use_block_editor_for_post_type/)`wp-includes/post.php` |

Returns whether a post type is compatible with the block editor.

  | 
| [WP_Customize_Nav_Menus::ajax_insert_auto_draft_post()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus/ajax_insert_auto_draft_post/)`wp-includes/class-wp-customize-nav-menus.php` |

Ajax handler for adding a new auto-draft post.

  | 
| [unregister_post_type()](https://developer.wordpress.org/reference/functions/unregister_post_type/)`wp-includes/post.php` |

Unregisters a post type.

  | 
| [WP_Customize_Nav_Menu_Item_Setting::populate_value()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menu_item_setting/populate_value/)`wp-includes/customize/class-wp-customize-nav-menu-item-setting.php` |

Ensure that the value is fully populated with the necessary properties.

  | 
| [WP_Screen::get()](https://developer.wordpress.org/reference/classes/wp_screen/get/)`wp-admin/includes/class-wp-screen.php` |

Fetches a screen object.

  | 
| [export_wp()](https://developer.wordpress.org/reference/functions/export_wp/)`wp-admin/includes/export.php` |

Generates the WXR export file for download.

  | 
| [_wp_ajax_menu_quick_search()](https://developer.wordpress.org/reference/functions/_wp_ajax_menu_quick_search/)`wp-admin/includes/nav-menu.php` |

Prints the appropriate response to a menu quick search.

  | 
| [get_calendar()](https://developer.wordpress.org/reference/functions/get_calendar/)`wp-includes/general-template.php` |

Displays calendar with days that have posts as links.

  | 
| [get_ancestors()](https://developer.wordpress.org/reference/functions/get_ancestors/)`wp-includes/taxonomy.php` |

Gets an array of ancestor IDs for a given object.

  | 
| [wp_count_posts()](https://developer.wordpress.org/reference/functions/wp_count_posts/)`wp-includes/post.php` |

Counts number of posts of a post type and if user has permissions to view.

  | 
| [is_post_type_hierarchical()](https://developer.wordpress.org/reference/functions/is_post_type_hierarchical/)`wp-includes/post.php` |

Determines whether the post type is hierarchical.

  | 
| [wp_xmlrpc_server::wp_getPostType()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_getposttype/)`wp-includes/class-wp-xmlrpc-server.php` |

Retrieves a post type.

  |

[Show 7 more](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/post_type_exists/?output_format=md#comment-content-1048)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/post_type_exists/#comment-1048)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_type_exists%2F%23comment-1048)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_type_exists%2F%23comment-1048)
 4. **Basic Examples**
 5.     ```php
        $exists = post_type_exists( 'post' );
        // returns true
    
        $exists = post_type_exists( 'page' );
        // returns true
    
        $exists = post_type_exists( 'book' );
        // returns true if book is a registered post type
    
        $exists = post_type_exists( 'xyz' );
        // returns false if xyz is not a registered post type
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_type_exists%2F%3Freplytocom%3D1048%23feedback-editor-1048)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_type_exists%2F)
before being able to contribute a note or feedback.