Delete CustomPress post type with code


I’m working on a multisite install that will allow sites to select which Custom Post Types they want to use. I’m using the import code ($CustomPress_Core->import) to install the CPTs when they’re requested, but is there a parallel way to remove unwanted CPTs? (e.g., $CustomPress_Core->delete($post_type_slug) or something)

Thus far, the only solution I’ve found is going to the CustomPress Dashboard and deleting it from there, but overall I was trying to avoid having users even see the CustomPress Dashboard, so a code solution would be preferable.


  • Dan
    • WPMU DEV Initiate

    I already know how to hide the menu item. The issue is that, if I can’t remove the post types the same way I can add them (with code), then the menu item needs to exist because there’s no other way to remove them.

  • Adam Czajczyk
    • Support Gorilla

    Hello Dan!

    I think this can be done with a little help of additional code. This should be helpful:

    Some code tweaking may be needed to adjust it to your specific needs but it should let you remove custom post types (and associated menu item) on demand.

    The content of these posts however would still remain intact inside the database so in case you’d like to remove it also you would want to craft a code using core WP functions that would search the DB against posts of selected type and then delete them. The code should fetch all “post_id” values from “wp_posts” table for all posts of certain “post_type”. Once these posts would be removed, it should also search “wp_postmeta” table for previously fetched “post_id” and remove those records as well.

    I hope that helps!

    Best regards,


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.