7

Seems like I can't have the same image in different galleries with different captions. Is it possible to make that working in any way?

Like if we could change the shortcut code that Wordpress is creating when you insert a gallery. Maybe to something like this:

[gallery]
    [image 244 caption="Caption 1"]
[/gallery]

[gallery]
    [image 244 caption="Caption 2"]
[/gallery]

The best would be to get this working with Wordpress's own gallery functionality. So when you click "Insert gallery", the above code will be placed in the texteditor. Then of course also change the code that handle these shortcodes.

I have of course searched through internet for answers before writing here. Couldn't find any.

  • I believe the caption is a property of the image and not of gallery. Meaning, you set the caption to the image, and the gallery will use whatever caption that image has. You could use the gallery_style filter to change the output and set it to get the caption from other available fields such as image alt text and image description. gallery_style filter -> core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/… – gdaniel Jan 14 '15 at 17:14
  • Yes I know it's the property of the image. That's what the problem is about. How to override it, like you can override it when you for example add a singel image to the content. I'm aware of gallery style filter. But that can't fix this problem. The titles and descriptions are also strict connected to the image the same way caption is. – Peter Westerlund Jan 14 '15 at 17:26
  • Right, but if the image description field is not being used, you could use the value as a alternative caption, and then use the gallery_style filter to print out the image description value as a caption. Or you could add custom fields. For example -> wpbeginner.com/wp-tutorials/… – gdaniel Jan 14 '15 at 17:32
  • 1
    Sorry but I don't like that solution. Actually can't really see how that would work either. How the galleries would know what text to use. I want to be able to create as many number of galleries and captions to an image as I want to. If this isn't possible with WP's own gallery, I will have to create the gallery with own shortcodes that isn't created by WP's gallery management. Little more tricky for the user, but open to more possibilities. – Peter Westerlund Jan 14 '15 at 17:50
  • @PeterWesterlund did you ever find a satisfying solution? – Graveto Sep 8 '17 at 10:00
0

Say you have image foo.jpg and bar.jpg in your media library. foo.jpg has caption saying "foo", and bar.jpg has caption saying "bar".

Create a gallery with those two images, they will show with "foo" and "bar" captions.

Want to use them again with a different caption, but using a gallery? No problem. Make another gallery and add the two images, changing their gallery captions to say "abc" and "def".

Now, the caption of foo.jpg will be changed to "abc". But it will still show "foo" in the first gallery where it was inserted with that caption.

At least that's how it works on my test site. Newest WordPress with Gutenberg "enabled".

And the same goes for single images - caption is changed, but the caption used on a page/post remains the way it had been initially set.

I could include the links, but think it's not needed - you can easily test it yourself.

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.