Home › Forums › Add-ons › Repeater Field › If repeater subfield has this value in any row : do something › Reply To: If repeater subfield has this value in any row : do something
The only way that you can find if any row has the true false field set to true is to loop over the entire repeater and test every rows. When you use
$rows = get_field('repeater');
the format of $rows will be something like
$rows = array(
// each row is a nested array
array(
// each subfield is a key => value pair
'sub_field' => 'value'
)
)
$has_true = false;
foreach ($rows as $row) {
if ($row['sub_field'])) {
$has_true = true;
break;
}
}
if ($has_true) {
// do something
}
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.