A few months ago, I complained about the image caption system WordPress implemented in regards to making alt text the same as the caption for any image inserted. I am now back for round two of complaints!
Last night, I encountered a problem. Whenever I tried to insert a hyperlink into text contained in an image caption, it disappeared when I posted or edited the entry, or when I switched to HTML view. I had realised that WordPress does not allow you to insert hyperlinks into captions! Although this is bothersome, it is fairly easy to work around.
The following is an example of what you might see in the HTML view if you use WordPress’s “insert image” feature and add a caption (note that I had to replace square brackets with curly brackets):
{caption id="attachment_000" align="aligncenter" width="100" caption="This is the caption below the image"}<img title="Further information" src="http://domain.com/image.png" alt="A description of the image" width="100" height="100" />{/caption}
When WordPress formats like this, it is impossible to insert hyperlinks into captions. There is quite a simple fix, however, which involves looking at the actual outputted HTML in the posted/previewed page’s source and manually coding the image and its caption:
<div id="attachment_000" class="wp-caption aligncenter" style="width: 100px;"><img class="size-full aligncenter" title="Further information or description" src="http://domain.com/image.png" alt="A description of the image" width="100" height="100" />
<p class="wp-caption-text">This is the caption for the image. <a href="http://domain.com">Look, a hyperlink!</a>.</p></div>
Pretty simple, but I do wonder why WordPress doesn’t allow you to insert a simple hyperlink into a caption. I mean, really…


