map showing above content with shortcode use

Home Forums MapPress Support map showing above content with shortcode use

Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #16640

    Hi Chris,

    I need to pass a post id (rather than a map id) to the mappress shortcode, so I’m using a custom shortcode below.

    The problem is that the map is always displaying above my content. It doesn’t display where I put my [mastermap post_id=”1″] shortcode. The default map setting is set to not display anything, so I can’t figure out why this is happening.

    Any thoughts? Maybe there is a different way to achieve what I’m trying to do?

    add_shortcode( 'mastermap', 'get_map' );
    function get_map( $atts ) {
    global $wpdb;
    $defaults = array('post_id' => '');
    extract(shortcode_atts($defaults, $atts));
    $value = shortcode_atts($defaults, $atts);

    $p_id = $value['post_id'];
    $mapid = $wpdb->get_var($wpdb->prepare("SELECT distinct mapid FROM {$wpdb->prefix}mappress_posts s WHERE postid=%s", $p_id));
    echo do_shortcode('[mappress mapid="'.$mapid.'"]');



    It’s hard for me to say – I only see part of the shortcode function, so it would help if you can paste the entire thing or email it to me. The default position setting only applies to ‘mappress’ shortcode, so that’s probably not the issue.

    Is it possible the mastermap shortcode is echoing its output rather than returning it? You might try just returning a string like ‘mastermap here’ from the shortcode, with nothing else, to see that the shortcode output is positioned correctly without a map.

    You might also want to look at the ‘mappress’ shortcode in file ‘mappress.php’ for an example of how the maps are output by default.


    Thanks. It did work to change echo to return.

    I ended up using the mappress shortcode code from mappress.php in my custom shortcode, so that I can use all the other parameters if needed. Thanks for the tip!

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