I'm using ACF Fields plugin and attempting to create a Google Map which shows post locations, but not getting very far - the pins show up in the wrong places, and when I echo out the title of the post in the HTML bubble above the pin, it's always the same post.. but in 3 different places. I only have 2 out of 10 posts with locations at the moment, so I have no idea why 3 places are being shown.. One is in the middle of the ocean as well. However, this is the closest I've come, and I've wasted the whole day trying...
<div class="acf-map"> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();?> <?php $location = get_field('location_map'); ?> <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div> <?php endwhile; wp_reset_postdata();?> </div>
I'd have thought this would be relatively simple to achieve, but I guess not.. but then I'm far from the best coder in the world :)
If anyone can give me any pointers on this, I'd be most grateful!