admin管理员组文章数量:1415476
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.
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.
Share Improve this question asked Jan 14, 2015 at 16:21 Peter WesterlundPeter Westerlund 1,0775 gold badges14 silver badges31 bronze badges 6- 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/browser/tags/4.1/src/wp-includes/… – gdaniel Commented Jan 14, 2015 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 Commented Jan 14, 2015 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/wp-tutorials/… – gdaniel Commented Jan 14, 2015 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 Commented Jan 14, 2015 at 17:50
- @PeterWesterlund did you ever find a satisfying solution? – Graveto Commented Sep 8, 2017 at 10:00
1 Answer
Reset to default 1Say 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.
本文标签: shortcodeHow to have different captions for same imagefor galleries
版权声明:本文标题:shortcode - How to have different captions for same image, for galleries? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745169958a2645913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论