Home › Forums › General Issues › How to move category ACF data to tag ACF data?
I am planning to convert all categories into tags but I have ACF data connected to the categories. I tried moving 1 category but the ACF data from the category was not moved into the tag ACF data. Is there a way to move category ACF data to the tag ACF data? I have hundreds of category ACF data so it will be really time-consuming if I move them manually. If there’s a way, how can I do it? Thank you.
There is no automated way to move the data from one to the other.
Data is stored in the _termmeta table by the term_id. When you create a new “category” this is a new term with a new term_id even if the name/slug is the same as the original “tag”.
Moving the data would require doing an DB search for all the _termmeta connected to the old term_id and replacing it with the new term_id.
You could, potentially, use the WP create_term hook. In the hook you could search the tags for a matching slug and then copy all of the ACF fields using get_field() and update_field(). Note that you will need to use the field keys to do the update process and NOT the field names.
Thanks. Let’s say categories are converted into tags, will the data added before the categories were converted be deleted? Since they are integrated into some posts.
The only time that ACF data is deleted is when you delete the thing that the data is attached to (post, term, user) and this is done by WP cleaning up the mata data for the deleted thing and not by ACF.
Thanks for the details. Another question. How do I know the metakey of a text field integrated within posts. For example, the text field name is product-name.
I thought you were using moving terms from one taxonomy to another. Post values will not be affected.
In all cases the meta key is the same as the field name.
You must be logged in to reply to this topic.
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.