I am creating posts by using wp_insert_post function. It works fine as I provide values in array required. Sometimes it is required to create a post having gallery. Without any problem, it also works fine.
But when there is requirement of adding captions to gallery images, I'm not able to add them programmatically. All captions are stored in an array.
Is there a way or hook to add them in gallery by code? Or in other way how to add caption array element beneath each image of gallery?