On mashup maps show post link and thumbnail on popup on marker click

How can I show show post link and thumbnail on popup on marker click on mashup maps created using [map query=”all”]. I don't want to change all that things manually but automaticly with the info from the post; just like [agm_gwp_geocoded_posts] does.

  • Kasia Swiderska
    • Support nomad

    Hello Marnick,

    I'm afraid that at the moment it is only possible to have link to post inside a marker using [map] shortcode and you have to always remember to associate map with post when you place map in post, using map settings:

    However Show images is not option for featured images - it was used for something called Panoramio Images that is no longer supported by Google Maps and this is not working (we are going to remove that option from plugin in future release).

    It is however possible to use featured images as markers, by enabling add-on "Featured image as map marker" in Google Maps plugin.

    and then using shortcode like that:

    [map query="all" show_posts="true" overlay="true" featured_image="yes"]

    I will ask one of our developers if this is possible to add featured images on markers with quick code snippet. I will let you know about their feedback.

    kind regards,

  • Panos
    • SLS

    Hi Marnick van den Brand ,

    Of what I understand you need to show the post thumbnail in the popup that appears after clicking on the marker but without changing the marker's icon right?

    If so, you can try adding the following snippet in a mu-plugin:

    add_filter( 'agm-create-tag', function( $map, $overrides ){
    	$markers = $map['markers'];
    	if (!$markers) return $map;
    	foreach ($markers as $mid => $marker) {
    		if (!isset($marker['post_ids']) || !isset($marker['post_ids'][0])) continue;
    		$post_id = $marker['post_ids'][0];
    		$image =get_the_post_thumbnail( $post_id, 'thumbnail' );
    		if (!$image) continue;
    		$markers[$mid]['body'] = $image;
    	$map['markers'] = $markers;
    	return $map;
    }, 30, 2 );

    This requires thought the map has been associated with the post.

    In case you are not familiar with mu-plugins you can read more about them here:

    Instead of mu-plugins you could add the snippet in your child-theme's functions.php. I would recommend to use a mu-plugin so it doesn't get removed in case you change theme etc.

    Hope this!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.