Home › Forums › General Issues › Querying relationship with True / False › Reply To: Querying relationship with True / False
Hi John,
This is a bit hard to explain. However, I wanted to display all the course providers who has a true value(1) within the relationship. Instead I got all the course providers who has a true value(1) within and apart from the relationship. Sorted this out with a radio field by following code. (should be possible with TRUE/FALSE as well)
<?php while ( have_posts() ) : the_post();
$rto_providers = get_posts(array(
'post_type' => 'rto_providers',
'meta_query' => array(
array(
'key' => 'courses_offered',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
?>
<?php if( $rto_providers ): ?>
<?php foreach( $rto_providers as $rto_provider ): ?>
<?php if( get_field('account_activation', $rto_provider->ID) == 'Active' ): ?>
<div class="row bordered-row random">
<div class="col-md-2 providers-list">
<?php echo get_the_post_thumbnail( $rto_provider->ID ); ?>
</div>
<div class="col-md-8">
<a href="<?php echo get_permalink( $rto_provider->ID ); ?>">
<?php echo get_the_title( $rto_provider->ID ); ?>
</a>
</div>
<div class="col-md-2">
<a href="<?php echo get_permalink( $rto_provider->ID ); ?>" class="btn btn-base">
Visit Page
</a>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endwhile; ?>
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.