Remove a custom post type from WordPress

WordPress
// PHP

What it does

This snippet will remove a custom post type from your WordPress website.

Note: Technically this will just remove connections from your website to this post type, but the posts’ entries will still be in your database.

The Code

function guyPrimavera_unregister_custom_post_type(){
    unregister_post_type( 'post_type_name' );      // Replace 'post_type_name' with your post type
}
add_action('init','guyPrimavera_unregister_custom_post_type');

How To Use It

Paste this snippet into your theme's functions.php or in a WordPress plugin.

Menu