Tell us what you are trying to do?
I am trying to insert 100+ values into a repeating field that stores images. I am getting the information from an API. I noticed that any record with more than 100 images does not store any of the images. I am trying to figure out if there is a bug with those particular records or if there is a limit in Toolset. I would expect that if there is a limit, it would stop at 100 instead of not storing anything. I am using add_post_meta to add the images.
if($c == "media") {
$photos_array = $this->handleMedia($prop->media);
if (is_array($photos_array)) { //sanity test to make sure you didn't blow up the array above
// delete existing values
delete_post_meta($post_id, 'wpcf-' . $c);
foreach($photos_array as $single_url) { // break the array down into single entries
// add
add_post_meta($post_id, 'wpcf-' . $c, $single_url, false);
echo " $c - " . $single_url . "\n";
/*
need to rework. see: https://stackoverflow.com/questions/47720297/how-to-update-post-meta-data-with-multiple-values
if($newp) {
add_post_meta($post_id, 'wpcf-' . $c, $single_url, false);
} else {
update_post_meta($post_id, 'wpcf-' . $c, $single_url, false);
}
*/
}
}
}
Hi,
Thank you for contacting us and I'd be happy to assist.
There is no hard limit set from Toolset or WordPress over the number of repeating custom field entries that can be saved with a post.
Do you see any error or warning in the server's error logs, when the images are not saved? I'll also recommend checking:
- is there any rate limiting involved from the API that you're using to get those images
- your code is not hitting any time-out or max execution time limits set by your hosting server
regards,
Waqar
Thank you. I figure it out. The field in the database that was storing the json data was set to TEXT. With 100+ images, this string was too long for that field type. As a result, when it came time to read the field and add the images to WordPress, the script could not properly parse the incomplete JSON string. Thanks for your help!
Thank you for sharing this and glad that this is sorted out.
You're welcome to mark this ticket as resolved and start a new one for each new question or concern.
My issue is resolved now. Thank you!