Hi,
I seem to be having a hard time making this work.
I have a repeater (resources) that outputs an array of downloads on a specific page. All good, works fine.
What I am trying to do now is only show specific repeater rows if a checkbox subfield has been checked. There are only two checkboxes and either one, or both can be checked.
I can get it to work with just one checked, but not both.
Here is what I have;
<?php if( have_rows('resources') ): ?>
<?php while( have_rows('resources') ) : the_row(); ?>
<?php $colors = get_sub_field('show_for');
if( $colors && in_array('usersme', $colors) ) { ?>
TEST
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
I think I need an ‘if this box is checked OR if this and this box is checked’ function but I’m a bit lost.
You can adjust it to use an OR operator by something like:
<?php if( have_rows('resources') ): while( have_rows('resources') ) : the_row();
$colors = get_sub_field('show_for');
if( !empty($colors) && ( in_array('usersme', $colors) || in_array('other_value', $colors) ) { ?>
TEST
<?php } endwhile; endif; ?>