Home › Forums › Add-ons › Repeater Field › Passing value from loop to nested loop › Reply To: Passing value from loop to nested loop
Use get_sub_field() to get the value and put it into a variable and then reverence that value in your nested loop.
if (have_rows('repeater')) {
while (have_rows('repeater')) {
the_row();
// get a field from this row to use in nested loops
$reference_a = get_sub_field('some_field');
if (have_rows('nested_repeater')) {
while (have_rows('nested_repeater')) {
the_row();
// get a field from this nested repeater to use later
$reference_b = get_sub_field('some_field');
if (have_rows('nested_repeater_x')) {
while (have_rows('nested_repeater_x')) {
echo $reference_a ,': ',$reference_b;
}
}
}
}
}
}
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.