hello
i am developing a plugin
i have a image url and with php save that inside upload folder
how can to update a gallery filed of a post with that image,
with
update_field($selector, $value, [$post_id]);
i just can update text value not gallery values
Are you using media_sideload_image() to import the image to the media folder? It is not clear that this is the case. The image most be in the DB to add it to an ACF field.
A gallery field holds an array of attachment IDs.
// return array of current image IDs
$gallery = get_field($selector, $post_id, false);
if (!$gallery) {
$gallery = array();
}
$gallery[] = $new_attachment_id;
update_field($selector, $gallery, $post_id);