Home › Forums › Front-end Issues › Conditional check of true/false field on another page – Advanced Custom Fields › Reply To: Conditional check of true/false field on another page – Advanced Custom Fields
The checkbox field ‘is_head_office’ is a sub field of the ‘office’ repeater, correct?
If so, you can’t access it’s value with var_dump( get_field('is_head_office' , 382) );
as you must be within a loop to see the current row’s value.
I would code it like so:
<h2>Head Office</h2>
<?php while(has_sub_field('office', 382)): ?>
<?php if( get_sub_field('is_head_office')): ?>
<?php the_sub_field('city'); ?>
<?php the_sub_field('address'); ?>
<?php the_sub_field('telephone'); ?>
<?php endif; ?>
<?php endwhile; ?>
<h2>Other Offices</h2>
<?php while(has_sub_field('office', 382)): ?>
<?php if( !get_sub_field('is_head_office')): ?>
<?php the_sub_field('city'); ?>
<?php the_sub_field('address'); ?>
<?php the_sub_field('telephone'); ?>
<?php endif; ?>
<?php endwhile; ?>
Hope that helps.
Thanks
E
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.