2

I would like to show different captions for the same image, used in multiple galleries.

Apparently it is not possible to save the caption of an image without changing that caption in all other occurences of the same image in other galleries as well.

Pretty much the same question was asked here : How to have different captions for same image, for galleries? But it was never fully answered.

Alternatively, if there is a way to style images as a gallery without having to upload them as a gallery - that would be good too. As the "edit image" offers local changes when uploaded as a media attachment instead of a gallery.

3
  • 1
    You can try creating a custom field to store the caption for each occurrence.
    – Akash K.
    Sep 22, 2017 at 9:45
  • @AkashK. this does not work, as custom fields are also not saved with each gallery but instead with each image in all galleries. At least that's what happend when I tried it. If you tried it out and it worked please write an elaborate answer and the bounty is yours.
    – Graveto
    Sep 22, 2017 at 15:05
  • I've implemented some custom galleries with the help of ACF plugin. You can use repeater field to add "image + caption" field combination and create markup for same in the template. If you're ok with using ACF, I can provide an example.
    – Akash K.
    Sep 25, 2017 at 10:34

2 Answers 2

2
+25

The caption is stored in the image data. The only way to achieve what you require is to use multiple copies of the image and change the image data on each image. To better understand image data go ahead and download an image to your desktop then right click it, go to properties then the details tab. this is where the image meta data is set. WordPress does has a few image meta settings but does not cover all of them. I feel its better to compress images on a pc or mac using Caesium image compressor then once compressed then change the image meta on your PC or mac. Google does not like sites to use the same image multiple times on different pages as this should be put into a sprite image. Sorry to be the barer of bad news but I hope it helps you better understand image meta.

2
  • Ough yeah I'm not happy to hear that indeed ^^ I'm kind of suprised that this would be the only way as I can easily have multiple captions for the same image when I do not use galleries. I will try to confirm your answer and then reward the bounty
    – Graveto
    Sep 25, 2017 at 0:02
  • Images has 4 data information : Title, Caption, Description and Filename; So you can query one of this data according your needs. Few years ago I had to use Title for one gallery and Caption for the menu gallery. Sep 28, 2017 at 22:59
1

you can use Caption Shortcode on the image you want change caption like:

[caption]<image> Caption[/caption]

This is primarily used with individual images caption change.

for detail information how to use caption shortcode check link

update#1 25-9-2017

in above answer i clear that This is primarily used with individual images caption change.

but if you want to change image caption inside gallery group ,i think you can achieve this manually by jquery (i think it's the easyist way to do it )like so:

1-open any *.js file that already enqueued in your gallery page. ( *.js file you can find in page source)

2-put this little piece of code in

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

    function_name();
    } )( jQuery );
1
  • 1
    But, this can't be done with the gallery shortcode, that shortcode automatically generates everything. Sep 24, 2017 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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