Home › Forums › MapPress Support › Shortcode in bubble
Tagged: mashup, shortcodes
- This topic has 6 replies, 4 voices, and was last updated 9 years, 1 month ago by
jcheckis.
-
AuthorPosts
-
October 24, 2013 at 5:14 am #13625
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.
October 25, 2013 at 3:35 am #13631You 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).
October 25, 2013 at 10:44 am #13642Talking 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); ?>October 25, 2013 at 5:00 pm #13643@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); ?>
February 5, 2014 at 6:53 am #14184Hi 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!
February 7, 2014 at 11:55 am #14209Hi,
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-escapeFebruary 11, 2014 at 10:24 am #14225Chris,
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!
-
AuthorPosts
- You must be logged in to reply to this topic.