Tell us what you are trying to do?
1. We have a custom field "File Upload" with "Allow multiple instances of this field" selected.
2. We have an array $file_links with several file links.
3. How can we update the custom field "File Upload" value with the array?
4. We already tried
update_post_meta($post_id, 'wpcf-file-upload', $file_links);
but it seems that it does not work.
5. Please advise.
Hello,
For multiple instance field, you can try function add_post_meta(), for example:
delete_post_meta($post_id, 'wpcf-file-upload');
foreach($file_links as $k=>$v){
add_post_meta($post_id, 'wpcf-file-upload', $v);
}
More help:
https://developer.wordpress.org/reference/functions/delete_post_meta/
https://developer.wordpress.org/reference/functions/add_post_meta/
I have answered the thread you mentioned above, please check it, thanks
I have escalated that thread, please let me know if you need more assistance for this thread, thanks
Thanks, Luo.
The code in this thread does not work for a form with enabled AJAX and disabled option "Use the WordPress Media Library manager for image, video, audio, or file fields." (when one additional file is added a previous file is lost)
We shall recheck it when when there is a patch for https://toolset.com/forums/topic/ajax-does-not-work-when-uploading-additional-files-to-a-file-upload-field/
My issue is resolved now. Thank you!