I am creating a plugin that creates a new custom post type. How can I check if the custom post type has been created already (maybe by the user in functions.php for some other use)? Actually I would like to know what is the best way to go about it, maybe add a prefix to my custom post type to make it as unique as possible?

1 Answer 1


To check for the existence of a post type, use post_type_exists. For instance like this:

if ( ! post_type_exists( 'yourpt' ) {
     $args = array(
         // your new post type's arguments
     register_post_type( 'yourpt', $args )

As for the prefix, that's a matter of personal taste and how common you think the post type otherwise is. Personally, I don't think it's necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.