Shortcode in bubble

Home Forums MapPress Support Shortcode in bubble

Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #13625
    srolls
    Participant

    Is there a way to use short code in my map maker info bubbles? I am looking to use a theme icon or even a mp3 player which are in my themes shortcodes.

    #13631
    Chris
    Keymaster

    You can modify the template file map_poi.php to show whatever you like. Try using do_shortcode() to execute any shortcodes in the poi body. I think this would work:

    <div class='mapp-body'>
    <?php echo $poi->get_thumbnail(array('class' => 'mapp-thumb')); ?>
    <?php echo do_shortcode($poi->get_body()); ?>
    </div>

    This may not work for all shortcodes (such as those that need to load javascripts on the page).

    #13642
    robbie59
    Participant

    Talking about the bubble. I can not get my custom fields to show up. The custom fields are attached to the post the map is in. Please help, none of these worked.

    <?php echo get_post_meta(postid, street_address, true); ?>
    <?php $key=”street_address”; echo get_post_meta($post->ID, $key, true); ?>
    <?php echo get_post_meta(postid, ‘street_address’, true); ?>

    #13643
    Chris
    Keymaster

    @Robbie, it’s better to start a separate thread for your issue. But to answer your question, try this if your custom field is ‘street_address’:

    <?php 
      if ($poi->postid)
        echo get_post_meta($poi->postid, 'street_address', true); 
    ?>
    #14184
    jcheckis
    Participant

    Hi Chris,

    I tried the fix you had above for running other plugin shortcodes in the body of the poi body and it worked great. Thanks for that!

    However, the solution doesn’t seem to carryover to mashup maps. I was wondering if there’s a similar mashup template file where I can add do_shortcode()?

    Thanks for your time!

    #14209
    Chris
    Keymaster

    Hi,

    It’s actually the same template file for both single maps and mashups.

    How you do this depends on how the shortcode was programmed, where the shortcode is, and what you’re displaying in the mashup (based on the “mashup body” setting in the MapPress settings or the mashup shortcode).

    If you’re displaying the poi body in the mashup, and the shortcode is in the poi body, then the technique above should work.

    If you’re displaying post excerpts in the mashup, then MapPress will set up the poi body using WP function get_the_excerpt(). Unfortunately, the WP standard excerpt function strips out all shortcodes. This may be what is happening in your case.

    There are various workarounds for that problem. Try a quick search on ‘the_excerpt’ and ‘shortcodes’ in Google or the WordPress codex. Here are few examples that might help:

    http://andrewferguson.net/2012/07/22/using-shortcodes-in-the_excerpt/
    http://wordpress.stackexchange.com/questions/75631/the-excerpt-or-get-the-excerpt-with-shortcode-escape

    #14225
    jcheckis
    Participant

    Chris,

    The issue ended up being with the shortcode itself. I was displaying the poi body with the shortcode in the body, however, I was trying to reference a property ID that was different than what the other plugin was expecting – it’s a property management plugin. The shortcode was simply ignoring the ID I was giving within the individual properties’ maps and defaulting to that property. This made it look like the shortcode was working as intended for individual maps, but not in the mashup map – since it wasn’t a property page the shortcode didn’t have anything to default to. Maybe that will be helpful to someone in the future.

    Regardless, you were absolutely correct about the initial tweak allowing for shortcodes within mashup maps. It is working just fine now with the correct ID list. Thank you for the great support and potential resolutions!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.