WordPress ACF import by script needs save for Repeater field

I just made a script for importing a JSON feed to ACF custom fields pro.
When I insert a field which is just a normal field a ‘save’ action by click is not needed after import.

update_field('rating', $route['rating'], $post_id);

Everything goes well.
However when its a repeater field I use this code:

Read More
$startlocation = array();
$startlocation[] = array(
    'lat' => $route['startingSpot']['location']['lat'],
    'lng' => $route['startingSpot']['location']['lng'],
    'description' => $route['startingSpot']['nl'],
    'direction' => $route['startingSpot']['direction']
);
update_field('startlocation', $startlocation, $post_id );

It needs a click after the creation of the imported post. When I run the import again, the fields are filled in.

Does anyone know if i need a different script, or give a programmed click of the save, to add all the custom field, after a created post by script?

Thanks in advance,
Peter

Related posts

Leave a Reply

1 comment

  1. For a repeater field of act you have to use the field_key not the name.
    This was the answer to my question.

    $startlocation = array();
        $startlocation[] = array(
        'lat' => $route['startingSpot']['location']['lat'],
        'lng' => $route['startingSpot']['location']['lng'],
        'description' => $route['startingSpot']['nl'],
        'direction' => $route['startingSpot']['direction']
    );
    update_field('field_dhjawhdwkwkhd', $startlocation, $post_id );