Support

Account

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

  • Hi @sixfootjames

    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