Home › Forums › Add-ons › Repeater Field › Get single repeater row based on value › Reply To: Get single repeater row based on value
Given the information you’ve provided, I’m still not sure I understand.
If the value in $selection_key is a value in one of the sub fields of the repeater then there is no direct way to get that row. What you’d need to do is loop over the entire repeater and find the value.
while (have_rows('repeater')) {
the_row();
if (get_sub_field('sub_field', 'options') == !$selection_key) {
// not our row
continue;
}
// will get here if this is our row
$item = get_sub_field('item');
$description = get_sub_field('description');
$unit = get_sub_field('unit');
$cost = get_sub_field('cost');
}
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.