Skip Navigation

[Gelöst] programmatically add another value of a repeating custom field

This support ticket is created vor 1 Jahr, 8 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 1 Jahr, 8 Monate.

Assistiert von: Luo Yang.

Author
Artikel
#2446973
Edit-Industrial-manipulator-“test”-‹-Indeva-Group-—-WordPress.png
Edit-Group-‹-Indeva-Group-—-WordPress.png

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

#2447327

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

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.