Add fields with loop
-
Hi there,
I want to insert a different number of fields on each post. Therefore I use a foreach loop to generate the fields. And it actually works – the fields are outputted on the edit screen.
However after adding images in the fields and saving the post, the images disappear. I have searched for the field in the database and there is nothing. Why is the data not saved?
My loop looks just like this:
foreach($colors as $color){ $meta_boxes[] = [ 'title' => "Add images of " . $color->name, 'id' => 'id_'.$post_id . '_color_' . $color->slug, 'post_types' => ['product'], 'context' => 'normal', 'priority' => 'high', 'fields' => [ [ 'type' => 'image_advanced', 'id' => 'id_'.$post_id . '_color_' . $color->slug, 'name' => 'Tilf?j billeder', 'max_status' => false, ], ], ]; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Add fields with loop’ is closed to new replies.