Support

Account

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

Solved

A google map with all registereds persons

  • Hello,
    I’m french, sorry for my English!!
    I’m using version 4.4 with Divi.
    I have a question, do you think that it is possible to take all the data of a ACF google map field, to make a loop to display all the data of all registered users?
    I have a web site for a syndicate for winemakers. Everyone has a map that appears in a dedicated page with a map map to locate them.
    I would like to make a map where all winemakers appear from ACF’s google map.
    Thanks a lot for your help!
    Cordially

  • 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!

  • Hi,
    i found the soluce :

    
    $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);
    $title_vignerons = get_the_title();
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'" 
    <h4><a href="'.$link_vignerons.'" rel="bookmark"> '.$title_vignerons.'</a></h4></div>';
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>
    

    Hope this help someone!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.