I'm just looking for a relatively simple way to modify the default output when a standard post image with a caption is linked somewhere (generally to another page), so that the caption is included in the link. It currently resides outside of the link tag so that it doesn't link like the image does.
I'll eventually be moving the caption up so it overlays the image. It's just awkward that the image will link properly to a separate page, but the caption (which will be the title of the page that the link points to) will not.
The default output is currently:
<div id="attachment_xxx" style="width: 480px" class="wp-caption alignnone"> <a href="/about/history-mission/"> <img class="size-medium wp-image-1679" src="https://domain.com/wp-content/uploads/sample-image.jpg" alt="" width="470" height="313" srcset="[multiple image sizes]" sizes="[proper sizes]"> </a> <p id="caption-attachment-1679" class="wp-caption-text">History & Mission</p> </div>
- Any way to get that p.wp-caption-text to slide into the 'a' tag with the image???
If there is no link added to a photo, it should just behave normally. I also thought about using a gallery, but didn't see a way to make each image a unique link to other pages.
NOTE: For now I'm using the classic editor (w/ TinyMCE Advanced). Not sure if I'll switch to Gutenberg yet, as that would open a TON of possibilities up to the client that I would have to account for & style appropriately. Because, you know, clients...