Home Forums Backend Issues (wp-admin) Removing data from WP db after deleting a field group


Removing data from WP db after deleting a field group

    • TrishaM

    • April 21, 2016 at 4:35 am

    After modifying how certain metadata works with Posts, I’ve decided to delete a field group that is now no longer needed.

    BUT a number of posts still have that metadata associated.

    Just as a matter of hygiene, I’d like to remove that meta key and values from those posts, but I do not have the SQL skills to write the query myself. I DO have access via phpMyAdmin, and am skilled enough to use it (always carefully and after backing up first!), but I could use some help in writing the query that will search the wp_postmeta table, find those Posts that have that metakey, and delete the key and it’s value.

    Anyone good with SQL queries?

    Thanks in advance for any help!

    • James

    • April 22, 2016 at 3:28 pm

    Hi @trisham

    I believe you can do it like this:

    DELETE FROM wp_postmeta WHERE wp_postmeta.meta_key = "custom_field_name" OR wp_postmeta.meta_key = "_custom_field_name"

    If you have time, please learn more about SQL here:


    • TrishaM

    • April 26, 2016 at 2:03 am

    Thanks @james!

    That worked perfectly, and thank you for the link – I do try to learn more all the time, but for some reason SQL queries still make me a bit nervous, although I do always backup my DB first.

    Your help is much appreciated 🙂

  • Why don’t you add this feature to the plugin itself, when someone removes any custom field from the group, please try storing them in a list and then either you can add an option to allow deleting them from DB, or we will at least have key and can delete them all in a run. Sometimes we do it in a hurry and lots of the fields remain there for lifetime, so we should have at least some option.

  • Yes why is this not something to add to the plugin? I deleted a content item from a repeater, but it’s still showing on the frontend, it hasn’t been removed from the database. How do I solve this??

    • TrishaM

    • January 21, 2021 at 9:41 am

    Respectfully I echo er.mayankrajput’s suggestion for consideration in a future update… option to delete – or not – the data already stored in the DB that is associated with the field (or repeater row) being deleted.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Removing data from WP db after deleting a field group’ is closed to new replies.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.