Home › Forums › Front-end Issues › Display Maps on Front-End › Reply To: Display Maps on Front-End
Using this code:
$map_posts = get_posts(array( 'post_type' => 'post', 'cat' => '8' )); if( $map_posts ): ?> <div class="acf-map"> <?php foreach( $map_posts as $map_post ) : $location = get_sub_field('location', $map_post->ID); ?> <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"> <h4><?php the_sub_field('title'); ?></h4> <p class="address"><?php echo $location['address']; ?></p> <p><?php the_sub_field('description'); ?></p> </div> <?php endforeach; ?> </div> <?php endif; ?>
Is there a way to show nearby locations? Like by a radius of 20 miles, for example?
P.s. Thank you so much for the code, it works great!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.