Home › Forums › Front-end Issues › Display Maps on Front-End › Reply To: Display Maps on Front-End
Hi,
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.