Languages: English • Italiano • 日本語 (Add your language)
This Conditional Tag checks if a post type exists by passing a post type name an argument. This is a boolean function and uses a global $wp_post_types variable for checking the post type existence, meaning it returns either TRUE if the post type exists or FALSE if it doesn't exist. The post type must be a registered post type.
<?php post_type_exists( $post_type ); ?>
if ( post_type_exists( 'book' ) ) { echo 'the Book post type exists'; }
$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
post_type_exists() is located in wp-includes/post.php
.
Post Types: register_post_type(), add_post_type_support(), remove_post_type_support(), post_type_supports(), post_type_exists(), set_post_type(), get_post_type(), get_post_types(), get_post_type_object(), get_post_type_capabilities(), get_post_type_labels(), is_post_type_hierarchical(), is_post_type_archive(), post_type_archive_title()