Hello, I already have this issue but not works with fields key.
If I insert the id of a post created manually it works fine. Any suggestions that I’ve not discovered?
Thanks a lot.
My code:
1. Create post programmatically
$id_post = wp_insert_post(array(
'post_type'=>$post_type,
'post_title'=>$post_title,
'post_status' => 'publish'
));
2. Update all the repeater fields associated to the “post_type”
$cliente_data = array(
array(
"field_582c2f15fab66" => 33
)
);
update_field( 'field_582c2ed4fab65', $cliente_data, $id_post );
Link of discussion:
https://support.advancedcustomfields.com/forums/topic/repeater-field-is-not-updating-data-with-programmatically-added-pages
Hi @andre9999
You should use the subfield name instead of the key for the repeater data. So, it should be like this:
$cliente_data = array(
array(
"subfield_name" => 33
)
);
update_field( 'field_582c2ed4fab65', $cliente_data, $id_post );
I hope this helps 🙂
@james
Thank you for the suggestion!
I’ve been tried for sure but it didn’t work.. but now yes!
Thanks for helping me, you’re magic 😀