Home › Forums › ACF PRO › Regarding Performance & DB Cleanup › Reply To: Regarding Performance & DB Cleanup
Orphaned meta data means that a corresponding post ID for a meta entry in the db no longer exists.
The issue is that meta data is related to the post and there is no relationship with the ACF field group, this means that if a field is deleted that the values saved in that field will not be deleted. There is no safe, scalable solution form removing this data.
There is an action in ACF that is called after the post for the field is deleted.
do_action( 'acf/delete_field', $field );
Using this hook you would need to query the meta table for the field key reference of the field.
WHERE meta_value = "{$FIELD_KEY}"
You could use this to get a list of all of the posts that this field was related to. With this information you could then delete all of the meta values
WHERE post_id IN {$LIST_OF_POST_IDS} AND meta_key IN ("{$field_name}", "_{$field_name}")
Not sure if this will help you or not.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.