Support

Account

Home Forums General Issues Converting a post_meta string into ACF? Reply To: Converting a post_meta string into ACF?

  • What you have is a serialized array. Yes, there is a way to create ACF fields and to populate the field with the existing information. There would be several steps involved, but if you’re looking to make the change automatically across all posts then it is not likely.

    The first step would be to create the ACF fields that you want to store this information in.

    The next step would be to create an acf/load_value filter for each of the ACF fields that you create. https://www.advancedcustomfields.com/resources/acf-load_value/. In this filter you would test to see if the ACF field already has a value and if it does not you would then get the value from where it is stored in the other format and return the new value. This step will only work in the admin, meaning that you’d need to edit and save every post. I would not open and save every post, instead I would do step 3.

    For step 3 you need to edit your template files and wherever these values are used you need to see if you should use the new fields or the old fields.

    
    $value = get_field('new_acf_field');
    if (!$value) {
      // get the value from the old data
    }