Home › Forums › Front-end Issues › Querying with ACF relationship values › Reply To: Querying with ACF relationship values
I’m going to pare down your code just a bit. If I understand you want to show the tout-more-specialists div, including everything in it, only if there are posts returned here $posts = get_field('doctor_specialties');
and show something else if not.
// move check for posts before opening div tag
$this_post = $post->ID;
$posts = get_field('doctor_specialties');
if( $posts ): ?>
<div class="large-4 medium-4 small-12 columns tout-more-specialists" data-equalizer-watch="bridge">
<div class="single-specialty-container">
<!-- rest of div content here -->
</div>
</div>
<?php
// add and else after the closing div
else: ?>
// you might need to do a reset here
wp_reset_postdata();
// put code to display something else here
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.