I recently installed the bonpress theme and am having trouble with the captions showing correctly. The more I try to understand how captions are supposed to work in WordPress, the more I suspect something is not happening right with my installation.
When creating a post and inserting an image with a caption, WordPress creates the following shortcode:
<a href="http://wordpress.local/wp-content/uploads/2012/10/2012-10-30-11.38.36.jpg"><img class="size-large wp-image-40" title="Torn motorcycle cover" src="http://wordpress.local/wp-content/uploads/2012/10/2012-10-30-11.38.36-e1351653272372-1024x984.jpg" alt="" width="1024" height="984" /></a> That's what I get for only spending $15 on a motorcycle cover
As I read through several pages such as the first example here and the sample code here (used by bonpress), it appears as though the caption should be passed as an attribute, e.g.:
If I manually enter the shortcode with caption
as an attribute, it renders correctly. Is something broken in my install that makes it so it doesn’t build it this way?
Update: The caption shortcode is constructed by image_add_caption
in /wp-admin/includes/media.php (line 134 in WP 3.4.2). The shortcodes are being constructed properly according to this code, so this leaves me wondering why all the code I can find regarding the customization of img_caption_shortcode
filter assumes the caption is an attribute?
Find the line
/* Remove [caption] in-line styling
infunction.php
.Comment out:
Find
.entry .wp-caption-text
instyle.css
. Change the style to suite your taste.Problem fixed. You are done.
I found an imperfect solution on here. Adding the following lines to the theme’s
fixed_image_caption_shortcode
function (previously identical to the one here) renders the captions as intended, but doesn’t add the caption as an attribute.This solution is sufficient, but hopefully someone has a better solution…
You should be able to force the shortcode back to default– to re-hijack it– by adding these two lines after that code runs:
That should set the shortcode back to the Core callback and undo whatever things that
fixed_img_caption_shortcode
broke.