Home › Forums › Add-ons › Repeater Field › Repeater field and checkbox › Reply To: Repeater field and checkbox
Hi @whoaloic
Hmm… A checkbox field will return an array of the selected values. You could use in_array()
function to to determine if a certain value is within the array as shown below:
if( have_rows('repeater_field_name') ):
while ( have_rows('repeater_field_name') ) : the_row();
$value = get_sub_field('checkbox_field_name');
if(in_array('value1', $value)) {
// display subfields
} else if(in_array('value2', $value)) {
// display other subfields
}
endwhile;
else :
// no rows found
endif;
For more info, check out:http://php.net/manual/en/function.in-array.php
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.