0

I'd like to add a caption to the entire gallery instead of single captions per photo. Is there a way to customize the shortcode to add a caption per gallery?

EDIT: I found somewhere how to add the metabox to the gallery popup and it's working but I don't know how to make the html output call that function...so, please if you guys can guide me it would be great.

//gallery add metabox
add_action('print_media_templates', function(){

// define your backbone template;
// the "tmpl-" prefix is required,
// and your input field should have a data-setting attribute
// matching the shortcode name
?>

jQuery(document).ready(function(){

  // add your shortcode attribute and its default value to the
  // gallery settings list; $.extend should work as well...
  _.extend(wp.media.gallery.defaults, {
    ds_text: 'no text'
  });

  // merge default gallery settings template with yours
  wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
    template: function(view){
      return wp.media.template('gallery-settings')(view)
           + wp.media.template('my-custom-gallery-setting')(view);
    }
  });

});

  • Do you mean same caption for each image or single header? Can you give an example? What have you tried so far? – birgire Mar 21 '18 at 8:30
  • Nope, I mean one single caption for the gallery. Like in a book where you have a caption to a box/grid of images of the same thing and they just put one caption below them. I have designed a caption style for my single images and I want that same style in galleries, but not 1 caption per photo but one caption in the whole wide of the photo grid – Cynthia Lara Mar 21 '18 at 14:46
  • edited with some code I found to add the option to the gallery shortcode – Cynthia Lara Mar 23 '18 at 16:50

Your Answer

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

Browse other questions tagged or ask your own question.