Ok guys,
I’ve managed to do that by make another get_posts query and by replacing ‘get_the_ID’ by a var $doctors_ID equals to :
$doctors_ID = $doctor->ID;
Same question for me,
Like @deian i have to build an history website with biography for people and projects from the beginning of the 20st century
Is there a solution ?
Cheers
<?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; ?>
ok i got it
<?php if( get_field('proj_annee') ): ?>
<h3>Année</h3> <?php the_field('proj_annee'); ?>
<?php endif; ?>
The answer was here :
http://www.advancedcustomfields.com/resources/how-to/hiding-empty-fields/
I just tried with this
<?php
if(get_field('proj_annee'))
{
echo '<h3>Année</h3>' . get_field('proj_annee');
}
?>
But the result of get_filed(‘proj_annee’) is ‘Array’
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.