How to Remove Custom Post Type with All Posts in WordPress

In this article, we will take a look into removing existing custom post types from the WordPress website with its posts.

You can remove any of your custom post types from your WordPress website by unregistering them, but it’s always a good practice to remove all the posts of the custom post types first and then unregister them from your theme.

Remove All Posts From Custom Post Type

You can remove all the posts of your custom post type, either manually from the WordPress dashboard or you can use the code snippet given below to remove them all at once.

Note: The code given below will remove all the posts from your custom post type in a single refresh, so please keep the backup of your posts or full backup of your website before using this to prevent any unexpected issues.

Add this code to your theme’s functions.php file, replace the post type name in the post_type parameter, and reload the WordPress dashboard. You will see all your custom post type posts got removed.

In the next step, we will unregister the custom post type from the theme.

Unregister Custom Post Type in WordPress

To remove any of the existing custom post types, we will unregister them from the theme by using the unregister_post_type('post_type_name') function.

Note: Remember, the unregister_post_type() function will only unregister the custom post types, it will not work with WordPress default post types.

Add the code snippet given below to your theme’s functions.php file, and pass the post type name in it.

Owner of, solely responsible for creating helpful, informative content about WordPress, a fulltime WordPress developer with 8+ years of hands-on experience in WordPress design and development.