Home › Forums › ACF PRO › Rename the field without losing existing content? › Reply To: Rename the field without losing existing content?
You cannot just rename a field, as you’ve found and there isn’t a simple way to do this.
There are two fields in the database that are associated with each field, not including group, repeater and flex fields.
The meta keys for these fields are $field_name
and '_'.$field_name
. The first one contains the field value and the second one contains the field key index. All of these meta keys need to be altered to the new field name. A warning, if this field name is not unique site wide then trying to do this in the database will result it you loosing data for other fields with the same name.
Since the field name is not seen, if you’re goal is to change the label so it makes more sense I would just change the label and leave the field name alone. Outside of dev for use in ACF function the name of a field really does not matter.
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.