Support

Account

Home Forums Front-end Issues A google map with all registereds persons Reply To: A google map with all registereds persons

  • Hi,

    I found this code and I adapted it to my needs, it works! How to add a link to the single.php of each person who appears on the map?

    $the_query_map = new WP_Query( array( 'post_type' => 'vignerons', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    
    if($the_query_map->have_posts()) :
    while($the_query_map->have_posts()):
    $the_query_map->the_post();
    $the_ID = get_the_ID();
    $link_vignerons = get_the_permalink();
    $get_google_map = get_field('carte', $value);
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'"></div>';
    
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>

    Thanks for help!