Tell us what you are trying to do?
===========================
Trying to add some images into a repeating image field using add_post_meta
Is there any documentation that you are following?
=========================================
Existing tickets
Is there a similar example that we can see?
Seems like this syntax isn't working properly. Can you confirm? Maybe it's how I'm passing on the array?
$image_urls = '<em><u>hidden link</u></em>';
// Turning comma separated string into an array
$image_array = explode(",",$image_urls);
// Delete all values
delete_post_meta($new_post_id, 'wpcf-photo-gallery');
// Add new values
foreach($image_urls as $single_image_url) {
add_post_meta($new_post_id, 'wpcf-photo-gallery', $single_image_url, false);
}
I found the solution myself. Much simpler, and works perfectly for Image Repeating fields
// declare your array contents
$image_array[] = "your absolute URL here #1";
$image_array[] = "your absolute URL here #2";
//use as many as you want above.. place an absolute URL between the quotes. P.S. You don't need to index the array above with 0,1, etc.. PHP does that automagically for you
if (is_array($image_array)) { //sanity test to make sure you didn't blow up the array above
foreach($image_array as $single_url) { // break the array down into single entries
add_post_meta($YOUR_POST_ID, 'wpcf-YOUR-FIELD-SLUG', $single_url, false); //add the contents to your custom post type's image field.
}
}
// replace YOUR-FIELD-SLUG, and YOUR_POST_ID above with whatever is appropriate.