Home › Forums › Add-ons › Repeater Field › If Sub_field equals… › Reply To: If Sub_field equals…
Unfortunately, there isn’t any easy way to do that, which is probably why it’s not documented anywhere. There have been a few questions related to this here here.
What you have to do is loop through the fields an look to see if the value exists and base the condition on whether or not is was found. The best way to do this depends on exactly what you’re trying to do as well as where and when you want to do it.
Let’s say that you wanted to show something extra after the loop, possibly the easiest option.
$found = false;
if (have_rows('repeater')) {
while(have_rows('repeater')) {
the_row();
if (get_sub_field('sub_field') == 'the value I'm looking for') {
$found = true;
// possibly collect more data from this row
}
}
}
if ($found) {
// do the extra stuff
}
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.