I,m I correct in saying, if I want to add images to a gallery_field, I need to supply the update_field() function a serialized array of attachment IDs?
Example:
$attachments_array = array('12','13','14',....);
$prep_array = serialize( $attachments_array );
update_field( 'field_0000000000', $prep_array ), $post_id );
Am I on the right track?
Hi @vividentity
Close, but you don’t need to serialize it.
Just pass through the array!
Also, you have a syntax error in your update_field function.
Thanks
E
Ops, Typo “)”.
O, OK… So how come you have to serialize for a relationship field? Is this because it saves it in a different way?
Anyway thanks for the confirmation!
THE SOLUTION:
$attachments_array = array('12','13','14',....);
update_field( 'field_0000000000', $attachments_array , $post_id );