Support

Account

Home Forums General Issues Importing serialized post_meta into ACF fields

Solving

Importing serialized post_meta into ACF fields

  • I’m rebuilding a website with a huge amount of post meta that needs to stay intact. Previously, the meta boxes were created and saved manually using add_meta_box and update_post_meta. All the metadata for each post is saved in a single record in wp_postmeta, with the post_id of the post, meta_key as the post type, and the meta_value as a serialized array of each meta box with its data.

    I want to create Advanced Custom Fields that map to these meta boxes and import this serialized data. However I realize that ACF stores the data in a completely different way, so I can’t just match up the field names. How can I go about importing this data and converting it to the ACF storage format?

  • HI @ryangiglio

    In this case, you need to unserialize the data and then use the update_field() function to update the fields.

    I hope this helps 🙂

  • Converting from cmb2, after setting up the ACF repeaters and then importing, are you saying to loop through the the db fields assigning the values to a variables, unserialize them, then use the update_field()?

  • Hi @optimize-worldwide

    I must have missed this response. Yes using the update_field() will ensure that the field value is properly formatted before save.

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

The topic ‘Importing serialized post_meta into ACF fields’ is closed to new replies.