Title: Caption not Working with Shortcode
Last modified: August 19, 2016

---

# Caption not Working with Shortcode

 *  [InHouse](https://wordpress.org/support/users/inhouse/)
 * (@inhouse)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/)
 * Hello, I am using Shortcoder v2.3 plugin to enable me to use HTML that the WYSIWYG
   editor (nor my client) will not break. I am using it successfully in a couple
   areas of the site but these captions will not work when used in conjunction with
   shortcodes or if I place the code in a template file. Any idea what it is that
   breaks? The images come up, but the caption code displays on the page as well.
 * `<div class="four-seasons-img-link">[caption class="cap" align="alignnone" width
   ="100" caption="Four Seasons"]<a class="events-img-link" title="Four Seasons 
   Gallery" href="http://cobtree.com/new/photo-gallery/four-seasons-gallery/"><img
   class="events-img-link" title="Four Seasons Gallery" src="XXX" alt="Four Seasons
   Gallery" width="100" height="66" /></a>[/caption]</div>`

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

 *  Thread Starter [InHouse](https://wordpress.org/support/users/inhouse/)
 * (@inhouse)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044089)
 * The preview doesn’t even look right so I know it’s not my CSS causing an issue.
   I place the same code in the page editor and it displays perfectly on the site,
   but then I use the shortcode instead and the caption displays funny. It’s live
   [here](http://cobtree.com/new). The 5 images on top is the code placed in the
   page editor and the 5 below is how the shortcode displays the same code. Is it
   because of the brackets the captions use??
 *  [Mike Thone](https://wordpress.org/support/users/mike-thone/)
 * (@mike-thone)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044434)
 * The shortcode API only works by default when displayed with the_content, like
   when it’s within the loop. This might be whats not working for you. To get shortcode
   to work outside the loop you need to use
 * `<?php echo do_shortcode('[yourshortcode]'); ?>`
 * So to get yours to work it should be something like this:
 *     ```
       <?php echo do_shortcode('
       [caption class="cap" align="alignnone" width="100" caption="Four Seasons"]<a class="events-img-link" title="Four Seasons Gallery" href="http://cobtree.com/new/photo-gallery/four-seasons-gallery/"><img class="events-img-link" title="Four Seasons Gallery" src="XXX" alt="Four Seasons Gallery" width="100" height="66" /></a>[/caption]
       '); ?>
       ```
   
 * Basically, write the shortcode between the (‘ ‘).
    I hope this solves your issue.
 *  [Mike Thone](https://wordpress.org/support/users/mike-thone/)
 * (@mike-thone)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044435)
 * Oh, and do it in your actual .php file. the WYSIWYG editor doesn’t allow the 
   <?php — ?> tags by default.
 *  Thread Starter [InHouse](https://wordpress.org/support/users/inhouse/)
 * (@inhouse)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044436)
 * [@mike](https://wordpress.org/support/users/mike/) – Shortcoder is a plugin that
   generates the shortcode for you. You write HTML in the plugin admin and place
   the shortcode in WYSIWYG. There’s no need to use PHP in the template files with
   this plugin. I’m using shortcode so my client doesn’t break my lengthy code in
   WYSIWYG. If you can, take a peek at Shortcoder. Makes it so you don’t need template
   files and the shortcode can be placed multiple times throughout site if need 
   be. So I think I still have a problem where my image code isn’t jiving with the
   Shortcoder plugin. Don’t know if its the caption brackets [ ] or what.
 * Last resort would be to use more templates files but it is overkill for what 
   I’m doing (placing 5 images in a page).
 *  [Mike Thone](https://wordpress.org/support/users/mike-thone/)
 * (@mike-thone)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044443)
 * I just took a look at the shortcoder plugin, and then checked back at your link.
   It looks like you fixed it. How did you get it to work?
 *  [soccerplayersbase](https://wordpress.org/support/users/soccerplayersbase/)
 * (@soccerplayersbase)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044444)
 * why not use jetpack? they have tons of shortcodes as i believe it’s a plugin 
   problem!

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

The topic ‘Caption not Working with Shortcode’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [soccerplayersbase](https://wordpress.org/support/users/soccerplayersbase/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/caption-not-working-with-shortcode/#post-2044444)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
