• InHouse

    (@inhouse)


    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

    (@inhouse)

    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. 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

    (@mike-thone)

    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

    (@mike-thone)

    Oh, and do it in your actual .php file. the WYSIWYG editor doesn’t allow the <?php — ?> tags by default.

    Thread Starter InHouse

    (@inhouse)

    @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

    (@mike-thone)

    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

    (@soccerplayersbase)

    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.