Title: Caption Problem
Last modified: August 20, 2016

---

# Caption Problem

 *  Resolved [pinatasaur](https://wordpress.org/support/users/pinatasaur/)
 * (@pinatasaur)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/)
 * Hello there! I used this theme as a boilerplate for a site, and am having some
   problems with how captions are handled.
 * On the page I’m editing, in the image panel, I put the text I want into the Caption
   field, and it looks like this in HTML view:
 * `[caption id="attachment_13" align="alignnone" width="300"]<img class="size-medium
   wp-image-13" alt="image" src="http://localhost/wordpress4/wp-content/uploads/
   2013/01/3whTg-300x300.jpg" width="300" height="300" /> Super Descriptive Caption
   Text! [/caption]`
 * Problem is, this does not get output as a caption on the page. It just shows 
   up as text, not wrapped in any kind of paragraph tags or anything. After doing
   some reading, I found a workaround, which involves changing things around manually
   like this –
 * `[caption id="attachment_13" align="alignnone" width="300" caption="Super Descriptive
   Caption Text!"]<img class="size-medium wp-image-13" alt="image" src="http://localhost/
   wordpress4/wp-content/uploads/2013/01/3whTg-300x300.jpg" width="300" height="
   300" />[/caption]`
 * And then it will show correctly.
 * But _every time_ I swap back from HTML view to Visual view, it puts the caption
   text back where it put it in the first place, and it goes back to being broken.
   Yet, if I switch to the 2012 theme, the captions work.
 * I put a test page up so you can see what I’m talking about without digging through
   a lot of content: [http://mdpmco.com/glamoursmiles/testpage/](http://mdpmco.com/glamoursmiles/testpage/)
 * The caption next to the picture of the dog (“This is a dog”) is _just_ text.
 * Is this a problem with the way the theme handles the caption shortcode output?
   It doesn’t seem to recognize the `[caption]<image>Content of Caption Field[/caption]`
   format that WordPress is using.

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/#post-3410699)
 * > Is this a problem with the way the theme handles the caption shortcode output?
 * yes – there was a change to the caption code in one of the last new versions 
   of wp;
 * have a look into /wp-includes/media.php from line 628.
 * your theme uses its own caption code which does not take those changes into consideration;
 * in functions.php of your theme, change the corresponding section to the code 
   below:
 *     ```
       function fixed_img_caption_shortcode($attr, $content = null) {
       $output = apply_filters('img_caption_shortcode', '', $attr, $content);
       if ( $output != '' ) return $output;
       	// New-style shortcode with the caption inside the shortcode with the link and image tags.
       	if ( ! isset( $attr['caption'] ) ) {
       		if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
       			$content = $matches[1];
       			$attr['caption'] = trim( $matches[2] );
       		}
       	}
       extract(shortcode_atts(array(
       'id'=> '',
       'align'	=> 'alignnone',
       'width'	=> '',
       'caption' => ''), $attr));
       ```
   
 * ….
 * (not widely tested)
 *  Thread Starter [pinatasaur](https://wordpress.org/support/users/pinatasaur/)
 * (@pinatasaur)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/#post-3410716)
 * That does seem to work! Thank you.
 * I’m going to go ahead and update the example I linked, but I put an example up
   here in case it’s useful to look at: [http://www.mdpmco.com/test/testblog/a-blog/](http://www.mdpmco.com/test/testblog/a-blog/)
   The dog picture and caption are the same.
 *  Thread Starter [pinatasaur](https://wordpress.org/support/users/pinatasaur/)
 * (@pinatasaur)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/#post-3410771)
 * Tangentially, is there a way to make the caption dependent on the width of the
   image it’s attached to? I’m sure this is just PHP ignorance on my part, but I
   can’t figure out how to make this theme do it.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/#post-3410801)
 * your latest link does not actually show any wp-caption code (?)
 * btw: I realized that I posted some code which does not seem to be in the latest
   version of the theme (version 3.1 updated 5 days ago).
 * as you are using 3.0, possibly updating might help?
 * genrally, the caption code should wrap the image and caption text into a container
   and thereby liniting the text to the width of the image;
 * this is the corresponding section from the 3.1 version of the function code:
 *     ```
       return '<figure ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: '
       . (10 + (int) $width) . 'px">' . do_shortcode( $content ) . '<figcaption ' . $capid
       . 'class="wp-caption-text">' . $caption . '</figcaption></figure>';
       ```
   
 *  [tidythemes](https://wordpress.org/support/users/tidythemes/)
 * (@tidythemes)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/caption-problem/#post-3410832)
 * That’s correct. The captions were fixed about a week ago.
 * But as you may or may not know, .org is primarily driven by volunteers in their
   free time, so it’s about a week wait before an updated theme is pushed live for
   that to be seen on the main theme page and for you to get an update notice in
   your WP admin in order to automatically update.
 * You can always check the SVN for the latest:
 * [http://themes.svn.wordpress.org/blankslate/](http://themes.svn.wordpress.org/blankslate/)
 * and then just manually change the download URL to whatever version you need:
 * [http://wordpress.org/extend/themes/download/blankslate.3.1.zip](http://wordpress.org/extend/themes/download/blankslate.3.1.zip)
 * But, you would need to manually upgrade as well.
 * In this case, simply go to Dashboard > Updates in your WP admin.
 * To get better help, quicker, please use the official forum in the future:
 * [http://tidythemes.com/forum/](http://tidythemes.com/forum/)
 * Thanks
 *  [rjain](https://wordpress.org/support/users/rjain/)
 * (@rjain)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/caption-problem/#post-3411047)
 * To follow up on this. I just updated to version 3.5 and I am having the same 
   issue. The captions are are showing up next to images. In the visual end of WP
   the image and caption looks fine but in preview or publishing it shows up next
   to image.
 * I tried changing the code in text but it changes back. Here’s the code in text.
 * [caption id="attachment_8241" align="alignright" width="200"]<img class=”size-
   full wp-image-8241 ” alt=”Obesity is a disease – changes to come?” src=”[http://www.livablefutureblog.com/wp-content/uploads/2013/06/RS65_girl-apples.jpg&#8221](http://www.livablefutureblog.com/wp-content/uploads/2013/06/RS65_girl-apples.jpg&#8221);
   width=”200″ height=”300″ /> Obesity is a disease – changes to come?[/caption]
 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/caption-problem/#post-3411048)
 * **[@rjain](https://wordpress.org/support/users/rjain/)** – see the post above
   yours from the theme author – he suggests you post in the theme’s dedicated forums
   for faster help – here:
 * >  To get better help, quicker, please use the official forum in the future:
   > [http://tidythemes.com/forum/](http://tidythemes.com/forum/)
 * Why not take advantage of that?
 *  [tidythemes](https://wordpress.org/support/users/tidythemes/)
 * (@tidythemes)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/caption-problem/#post-3411051)
 * Version 4.0 is here:
 * [http://wordpress.org/themes/download/blankslate.4.0.zip](http://wordpress.org/themes/download/blankslate.4.0.zip)
 * Let us know what you think here:
 * [http://tidythemes.com/tidythemes-sucks/](http://tidythemes.com/tidythemes-sucks/)
 * Thanks, TidyThemes

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Caption Problem’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/blankslate/2026/screenshot.jpg)
 * BlankSlate
 * [Support Threads](https://wordpress.org/support/theme/blankslate/)
 * [Active Topics](https://wordpress.org/support/theme/blankslate/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/blankslate/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/blankslate/reviews/)

## Tags

 * [caption shortcode](https://wordpress.org/support/topic-tag/caption-shortcode/)
 * [captions](https://wordpress.org/support/topic-tag/captions/)

 * 8 replies
 * 5 participants
 * Last reply from: [tidythemes](https://wordpress.org/support/users/tidythemes/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/caption-problem/#post-3411051)
 * Status: resolved