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?

  • Anyone, here to tell?
    – 10wtaylor
    Apr 25 '13 at 18:47

you can change caption programmatically by jquery something like this:

( function( $ ) {    
    function function_name() {
          $( '#gallery-<gallery_ID>-<image_ID>').text("new caption");

} )( jQuery );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.