Template tag

Home Forums MapPress Support Template tag

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #10510
    manunc
    Participant

    Hello,

    I need to display a map configured on admin side in a specific post, I see that each new created map have an ID.

    The tag to use is the following
    <?php echo do_shortcode('[mappress mapid="20"]'); ?>

    but how catch the map ID so that the query is working for every post?

    stg like:

    $mapid = get_post_mapid('TEST');

    <?php echo do_shortcode('[mappress mapid="$mapid"]'); ?>
    Thanks for your help

    #10511
    Chris
    Keymaster

    Hi, what version of the plugin are you using?

    #10512
    Chris
    Keymaster

    Hi,

    Here’s how you can get a list of maps for the post, then use the first map in the list:

    $maps = Mappress_Map::get_post_map_list($post->ID);
    if (!empty($maps)) {
    	$mapid = $maps[0]->mapid;
    	do_shortcode('[mappress mapid="$mapid"]');
    }

     

    #10513
    manunc
    Participant

    The last one I guess:
    Version:2.38.6 PRO

    #10514
    manunc
    Participant

    Thanks,

    Is there a way to directly get the mapid by filtering, giving the name of the map in argument ?

    exemple: a map id 2 has the name [2] Couleur du Lagon

    #10515
    Chris
    Keymaster

    Hi, no there’s no way to search by name.  If you’re just searching for one name in the current post, you could loop through the results from the get_post_map_list() function call.

    #10519
    manunc
    Participant

    Hello,

    I have disable automatic display in MapPress settings and I have added this in my listing.php page:

     

    <section id=”overview”>
    <?php the_content(); ?>
    <?php $maps = Mappress_Map::get_post_map_list($post->ID);

    if (!empty($maps)) {
    $mapid = $maps[0]->mapid;
    do_shortcode(‘[mappress mapid="$mapid"]‘);
    } ?>

    </section>

    Unfortunately no map is displayed

    Any idea?

    #10521
    manunc
    Participant

    I have almost finished the integration but I have a little issue:

    I used the following code to display the map:

    $coord = appthemes_get_coordinates( $post->ID );
    $mymap = new Mappress_Map( array(
    “width” => 750,
    “center”=> array(“lat” => $coord->lat, “lng” => $coord->lng),”zoom” => 19 )
    );
    echo $pro;
    $mypoi_1 = new Mappress_Poi(array(
    “title” => $pro,
    “body”  => $pro,
    “point” => array(“lat” => $coord->lat, “lng” => $coord->lng)
    ));
    $mymap->pois = array($mypoi_1);
    echo $mymap->display();

    But $pro that is retrieved with:

    <?php $pro = the_title(); ?>

    Does not show the title in the map,

    Any idea?

    #10528
    Chris
    Keymaster

    Hi,

    I wasn’t clear – is the_title() actually set but just not displaying in the map?  For example, if you print it instead of trying to map it, do you see it has a value:

    print_r(the_title());

    What happens if you just hardcode the map title, e.g.

    …title => ‘hello’…

    If that’s not the issue,  you could take a look at the poi template file to see if perhaps it’s not generating the HTML the way you need it.  The file is:

    /pro/templates/map_poi.php

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