Home › Forums › General Issues › Render multiple markers from Custom post onto a map › Reply To: Render multiple markers from Custom post onto a map
<?php
$posts = get_field('relation');
if( $posts ): ?>
<div class="acf-map">
<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT)?>
<?php $location = get_field('spot_lieu', $p->ID); ?>
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>">
<h4><?php echo get_the_title( $p->ID ); ?></h4>
<p class="address"><?php echo $location['address']; ?></p>
<p><?php echo get_the_post_thumbnail($p->ID); ?></p>
</div>
<?php endforeach; ?>
</div>
<ul>
<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
<li>
<a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_title( $p->ID ); ?></a>
<span><?php the_field('spot_lieu', $p->ID); ?></span>
<p><?php echo get_the_post_thumbnail( $p->ID); ?>
</p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
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.