WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Deleting a custom post type leaves annoying remnants lying around database (3 posts)

  1. Cory Simmons
    Member
    Posted 1 year ago #

    So I created a Custom Post Type called "services", I made some services and decided I wanted to change those services to child pages, so I deleted my custom post type via the Custom Post Type UI interface.

    I created my child pages and went to view their webpage and it wasn't displaying the right template.

    Immediately I knew it was a database issue and when I looked at my database, I noticed a bunch of "services" under the "post_type" column in wp_posts.

    I'm sure there are tons of relationships and such mapped to the old/deleted custom post type, and that's what's causing my example.com/services/foo pages to break.

    Is this an inherit problem with how WP deletes custom post types? If not, can you update the plugin to actually nuke the custom post types from the database completely? If not, does anyone know of a plugin that will do that?

    Thanks!

    http://wordpress.org/extend/plugins/custom-post-type-ui/

    Update Simple enough to fix. Just SELECT * FROM wp_posts WHERE post_type = 'services', then delete.

    I'm sure there are remnants somewhere else, but I'll cross that bridge when I come to it unless someone has a more elegant solution.

  2. Hube2
    Member
    Posted 1 year ago #

    I believe I ran into an issue with this as well where old data remnants caused an issue. I have been testing this plugin out to see what it does and I have been adding and deleting post types.

    Suddenly all my custom post types were not appearing in the WP Menu. The only way I could clear up the problem was to delete all of the data and reinstall WP and start from scratch.

    I think the main error that started causing my problems was a space in the custom post name of one of the custom post types I tested. It was after adding that one that all my troubles started. However, I think that if the remnants of this were not laying around in the database, I would not have needed to purge the DB and restart.

    Hope the info helps in some way, but I am in complete agreement that when the custom post type is deleted that all related data should be purged, perhaps with an option to apply any existing posts in a post type to another post type?

  3. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    Data deletion is a tricky subject to manage, as some people won't care, some people will. I'm a believer in offering the option that takes explicit permission to delete the plugin-created data, otherwise just leave it alone.

    With something like CPT posts, I think they should be left in unless otherwise told, because you could ditch this UI plugin and register the post type yourself in the exact same way, preserving and regaining all of the associated data with it.

    I'm going to note down for future consideration a button/checkbox/something that says "delete all plugin-created data".

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic