post_type_exists() WordPress Function

The post_type_exists() function can be used to check if a post type exists. This function can be useful when checking if a custom post type exists before registering it.

post_type_exists( string $post_type ) #

Determines whether a post type is registered.


Description

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

Top ↑

See also


Top ↑

Parameters

$post_type

(string)(Required)Post type name.


Top ↑

Return

(bool) Whether post type is registered.


Top ↑

Source

File: wp-includes/post.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.0.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