Home › Forums › Add-ons › Repeater Field › Have_rows breaks with options page, on page nesting mix › Reply To: Have_rows breaks with options page, on page nesting mix
The social_icons field is never a sub repeater. It is always a top level repeater. I just want to be able to access that top level repeater from within a sub repeater.
So, at the moment my solution is
while(have_rows("custom_modules", "option")) { // Can also be not an options page
the_row();
// Some stuff
while(have_rows("sub_modules")){
the_row();
$social_icons = get_field("social_icons", "options");
if(count($social_icons)>0) { ?>
<ul class="social-links">
<?php foreach($social_icons as $icon){ ?>
<li>
<a href="<?=$icon['social_url'];?>"><i class="fa <?=$icon['social_icon'];?>" aria-hidden="true"></i></a>
</li>
<?php } ?>
</ul>
<?php }
}
}
In my initial post, there is something about the 2nd have_rows() which makes accessing the options page in the 3rd have_rows() break the code.
You can access a top level field on the options page from within a repeater selected from the options page.
For example, this works.
while(have_rows("test", "option")) {
the_row();
if(have_rows("social_icons", "option")) {
while(have_rows("social_icons", "option")){
the_row();
the_sub_field('social_icon');
}
}
}
It selects social_icons from the top level, not as a sub field, and outputs the correct information.
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.