Events Manager
[resolved] Caption shortcodes not being parsed (9 posts)

  1. richplane
    Posted 4 years ago #

    Have been scratching my head over this one for hours.

    The [caption] shortcode isn't being parsed when we insert images into event descriptions and give them captions.

    Like this:

    We have been over and over our templates and theme files and can't find anything that we did that might have caused this, but searching the forum and googling doesn't turn up many others with this problem.

    Anyone got any suggestions?


  2. agelonwl
    Posted 4 years ago #

  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 4 years ago #

    have you tried it on the 20 11 theme? shortcodes should work fine with descriptions.

  4. richplane
    Posted 4 years ago #

    @aglonwl - Thanks - but I'm not sure what you're suggesting here. The client is entering event data and trying to insert images with captions as you would do on posts and pages. I don't think do_shortcode() will help.

    @Marcus - you say 'should' - do you know that they do work OK? None of the EM-powered sites I've seen have captioned images inline in the descriptions. The demo on demo.wp-events-plugin.com/ doesn't.

    We're using an events-single template, so it's the #_EVENTNOTES placeholder replacement that seems to be going askew.

  5. agelonwl
    Posted 4 years ago #

    I tried this one and seems to be working fine;

    on event details html, I have this

    [caption id="attachment_953" align="alignnone" width="300"]<a href="http://domain.com/assets/Mark-Lanegan-Band.jpeg"><img class="size-medium wp-image-953" title="Mark Lanegan Band" src="http://domain.com/assets/Mark-Lanegan-Band-300x221.jpg" alt="" width="300" height="221" /></a> Welcome[/caption]

    then on my Settings > Formats/Layouts > Event Formats > Default single event format I added this #_EVENTNOTES or for events-single template you can find sample snippet here - http://wordpress.org/support/topic/events-manager-eventslocation-pages-cant-get-sidebar?replies=20

  6. richplane
    Posted 4 years ago #

    OK, I disabled our theme template file and put a basic format in there hopefully sufficiently quickly that the client wouldn't notice.

    (Interestingly, simply selecting 'Yes' for "Override with Formats?" in Events -> Settings -> Pages didn't actually override the single-event template. I had to delete the file before the page updated. Anyway, beside the point.)

    The caption shortcode is indeed parsed correctly when I enter it directly into the Event Format textarea. So why doesn't it work when I do <?= $event->output('#_EVENTNOTES') ?> in our single-event.php template?

    - NB you'll note I misled you before. We're using a single-event.php template not an event-single.php one.

    We're setting $event from em_get_event($post->ID, 'post_id'); - can anyone see why the output method of the object this returns wouldn't parse shortcodes? Perhaps $event->output() expects the shortcodes to have already been parsed? Can't quite get my head around how this could work.

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 4 years ago #

    single-event.php is a WP template so it'll override anything we try, override with formats would still work providing you're outputting the_content()

    have you correctly instantiated $event? e.g.

    $EM_Event = em_get_event($post->ID, 'post_id');
    echo $EM_Event->output('#_EVENTNOTES');
  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 4 years ago #

    oops, skipped the last paragraph :)

    I'd try print_r($event) to make sure you have the right event then.

  9. richplane
    Posted 4 years ago #

    I've solved the problem.

    We obviously have the right event object - we're seeing the correct data being pulled through when I do

    <?= $event->output('#_LOCATIONLINK') ?>
    <?= $event->output('#_EVENTIMAGE{200,125}') ?>

    etc. etc.

    The problem is because we're using a WP template. WP will parse shortcodes in the_content() but we're not using the_content().

    The solution is to create an event-single template (at /themes/<theme_name>/plugins/events-manager/templates/event-single.php), which just runs $event->output('#_EVENTNOTES'). Then replace that call in the single-event.php theme template with the_content().

    Just in case (!) that's not clear to anyone: what's happening is that WordPress is pulling up the theme's single-event.php template for the event custom post type. When it see the the_content() call in this template, it gets hooked by Events Manager, which outputs its own template event-single.php into this spot.

    This is a great and powerful plugin; can't really complain about these confusions and the minimal documentation given that it's free.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.