Home Forums Backend Issues (wp-admin) Updating MySQL Database When Modifying ACF Groups


Updating MySQL Database When Modifying ACF Groups

  • Good day, all. I have been experimenting with ACF’s ‘Group’ and ‘Tab’ layout fields in order to improve their presentation within the WordPress Gutenberg editor for the custom post type I associated with an ACF field group. I noticed the MySQL “postmeta” table retains all the ACF custom field edits, even after I delete the unused fields and sub-fields when devising group and tab configurations.

    Unfortunately, the retained postmeta table ACF field and sub-field records are interfering with the data returned in my custom posts. This may result from the same-named “metakey” column field values, although this should not be an issue since each “postmeta” record is assigned a unique ID value. That is, I used the same ACF custom field “label” and “field” names, but I deleted previous incarnations of the same. I would have assumed ACF purges the appropriate “postmeta” records once their corresponding ACF custom fields & sub-fields are deleted from an ACF custom field group, but this does not seem to be the case.

    To mitigate this issue, I guess I will have to manually delete these records, although I am hesitant to do so, because this may produce orphaned records in the MySQL “posts” table. Therefore, I may need to delete records in the “posts” table as well. This is a hassle, especially when considering the underlying WordPress database structures are very denormalized, making it more tedious to trace the table-to-table relationships.

    Has anyone encountered a similar problem? I would appreciate your feedback. Thank you.

  • There is almost nothing that you can do about this, especially if you have used the same field names for the fields. You would need a list of all of the post IDs that have the wrong data and you’d have to delete the meta fields for those post IDs.

    The only real solution is to delete all of the posts that exist. (trash and then delete permanently). This will cause WP to delete all associated meta fields.

    And then start over with the fields that you want to keep.

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

You must be logged in to reply to this topic.