I can’t figure out how in the world to get the value of a checkbox entered in a repeater field. There is only one choice. Basically if the user ticks the checkbox it should output a class.
In the code example I don’t have the value in the class yet because I am just trying to get it to print something! arg.
Thanks for any and all help, I appreciate it!
<?php if( have_rows( 'milestone_module' ) ) : ?>
<section id="tao-timeline">
<?php
while( have_rows( 'milestone_module' ) ) : the_row();
// Vars
$milestone_module_date = get_sub_field( 'milestone_module_date' );
$milestone_module_copy = get_sub_field( 'milestone_module_copy' );
$field = get_field_object('milestone_long_date');
$value = get_field('milestone_long_date');
$label = $field['choices'][ $value ];
?>
<div class="tao-timeline-block">
<?php if( $milestone_module_date ) : ?>
<span class="tao-timeline-date">
<?php echo $label; ?>
<?php echo $milestone_module_date; ?>
</span><!--/.tao-timeline-date-->
<?php endif; ?>
<?php if( $milestone_module_copy ) : ?>
<div class="tao-timeline-content">
<?php echo $milestone_module_copy; ?>
</div><!--/.tao-timeline-content-->
<?php endif; ?>
</div><!--/.tao-timeline-block-->
<?php endwhile; wp_reset_postdata(); ?>
</section><!--/#tao-timeline-->
<?php endif; ?>
Updated code for true/false, still not working…
<?php if( have_rows( 'milestone_module' ) ) : ?>
<section id="tao-timeline">
<?php
while( have_rows( 'milestone_module' ) ) : the_row();
// Vars
$milestone_module_date = get_sub_field( 'milestone_module_date' );
$milestone_module_copy = get_sub_field( 'milestone_module_copy' );
?>
<div class="tao-timeline-block">
<?php if( get_field('milestone_long_date') ) { ?>
<span class="tao-timeline-date long-date">
<?php echo $milestone_module_date; ?>
</span><!--/.tao-timeline-date-->
<?php } else { ?>
<span class="tao-timeline-date">
<?php echo $milestone_module_date; ?>
</span><!--/.tao-timeline-date-->
<?php } ?>
<?php if( $milestone_module_copy ) : ?>
<div class="tao-timeline-content">
<?php echo $milestone_module_copy; ?>
</div><!--/.tao-timeline-content-->
<?php endif; ?>
</div><!--/.tao-timeline-block-->
<?php endwhile; wp_reset_postdata(); ?>
</section><!--/#tao-timeline-->
<?php endif; ?>
Chris, I’m fairly sure that this is how you would get this to work (for just the true/false segment):
Otherwise, if you had a radio field instead, I know the code for that. I’ve not had to work with true/false.
If it was a yes/no radio button:
I know the radio will work. I’d have to do some testing on the true/false to confirm.