Home Forums ACF PRO Imported data not being associated with field key in postmeta


Imported data not being associated with field key in postmeta

  • I’m working on a project where we are importing massive amounts of data (10k posts with about 300 fields a piece in a multi-site install). The import is assigning data to ACF fields based off of ACF field names and it’s all working great, or so I thought.

    The problem I ran into is that the ACF field keys (i.e. field_57e1462ba619c) aren’t being assigned to the postmeta for each post. I have a work around for most of the fields by running update_post_meta() on the the all of the fields to assign them to the ACF field keys. Unfortunately I’m not really sure how to do that with repeater fields that could have a varying number of of sub fields per post.

    Does anyone have any idea how to update the repeater fields to assign all of their sub fields to the correct ACF field key?

  • I personally use with the ACF add on.

    That being said, the best I can tell you is how repeaters are stored.

    The repeater field itself is stored in the database with the field name, this is the same as the other fields you’ve already worked with. This field contains the number of rows in the repeater. Each subfield of the repeater is stored as {$repeater_name}_{$row}_{$subfield_name} with rows starting a 0.

    The keys for these fields will be stored in another db entry starting with

    field           | field name in db     | field key meta name   | 
    repeater        | repeater             | _repeater             |
    row 1 subfield1 | repeater_0_subfield1 | _repeater_0_subfield1 |
    row 1 subfield2 | repeater_0_subfield2 | _repeater_0_subfield2 |
    row 2 subfield1 | repeater_1_subfield1 | _repeater_1_subfield1 |
    row 2 subfield2 | repeater_1_subfield2 | _repeater_1_subfield2 |

    Hopefully you don’t have any nested repeaters, but the pattern continues. A nested repeater will have the number of rows in the above field and then it’s own sub field

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

The topic ‘Imported data not being associated with field key in postmeta’ is closed to new replies.