Support

Account

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

Solved

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: http://www.w3schools.com/sql/.

    Thanks!

    • 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.

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

You must be logged in to reply to this topic.

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.