Hi, I'd like to programmatically add some values of a repeating custom field (repeatable image field, see screenshot).
According to this https://toolset.com/forums/topic/adding-a-number-to-a-repeating-field-via-php/ , I'm using just "add_post_meta".
This is my code: add_post_meta( $target_post_ID, 'wpcf-photogallery-image-industrial-manipulator', $miovalue );
It adds the row in the wp_postmeta table, but the image does not appears in the post edit page (see screenshot).
I see in the database that, if I add an image to the repeater field through the admin panel, a few records are created in the database , not just the one regarding wp_postmeta .
Can you please give me an advice on how to add images to a repeating custom field?
Ciao
Alessandra
Hello,
In your screenshot:
https://toolset.com/wp-content/uploads/2022/08/2446973-Edit_Group_Indeva_Group_WordPress.png
It is a repeatable field group, see our document
https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/
Toolset repeatable field group is based on one-to-many relationship, so each item of repeatable field group is also a single post, and the post type slug is the repeatable field group slug, you can find it in above screenshot, the post type slug is "photo-manipulators"
In your case, you can try these:
1) Insert a new "photo-manipulators" posts
https://developer.wordpress.org/reference/functions/wp_insert_post/
2) Update custom fields of "photo-manipulators" post
https://developer.wordpress.org/reference/functions/update_post_meta/
3) Connect the "photo-manipulators" post with parent "Industrial_manipulator" post
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts