In WordPress, after a custom post type has been registered, but before it has been associated with a post, it is available through the global variable $wp_post_types
. The function post_type_exists()
can be used to check if a particular type exists in that variable.
My question is, where in the WordPress database are custom post types saved before they are associated with a post? The documentation seems to suggest that they are saved in the wp_posts
table, but that table associates posts with types – it doesn’t store types that have no posts.
When you create a custom post type you will see in the sidebar in the dashboard, once you create at least one post, you can check for that post’s
post_type
column in thewp_post
tableYou can read more here
Besides, you can use some functions to check if a post type is registered.
get_post_types
post_type_exists