Support

Account

Home Forums Backend Issues (wp-admin) Find / replace on ACF wp_postmeta?

Solved

Find / replace on ACF wp_postmeta?

  • I initially setup a lot of content that references an ACF flexible content field called ‘standard_elements’. I’ve since changed the name of the field to ‘custom_content’. Now, all old entries to the database reference the old field name, and all new content references the new field name. Causing an issue pulling this data into the front end.

    I now understand that ACF doesn’t delete or auto rename any database content when a field name change is made, but I was wondering if I could do a find / replace on the database via phpmyadmin.

    Would this action break ACF (after all, it would only be bringing old ‘hidden’ content back into ACF’s gaze)? And if not, what is the best way to make this change?

    Thanks,
    Andy.

  • Found a relevant link. Is the process outlined by @elliot still best practice in ACF Pro? http://support.advancedcustomfields.com/forums/topic/best-practice-for-changing-custom-fields/

    To paraphrase @elliot, [write SQL in phpMyAdmin to the tune of…]

    UPDATE wp_postmeta
    SET meta_key = 'new_field_name'
    WHERE meta_key = 'old_field_name';

    and

    UPDATE wp_postmeta
    SET meta_key = '_new_field_name'
    WHERE meta_key = '_old_field_name';
  • OK. I followed the instructions in the post linked above and it worked fine. I had to re-run the query for the likes of…

    • custom_content_0_image
    • custom_content_1_image
    • custom_content_2_image

    So if anyone can note the SQL code to include such additions, for future reference, it would be much appreciated.

    Thanks,
    Andy.

  • The only issue that you’re going to have with this solution is if 'old_field_name' is not unique. It will cause any field with the old name to also be changed. This is the main reason that it’s pretty much impossible to build field name changes into ACF and why it has never been done despite many requests.

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

The topic ‘Find / replace on ACF wp_postmeta?’ is closed to new replies.