Home › Forums › General Issues › Nested repeater within flexible content › Reply To: Nested repeater within flexible content
Hi @theshae
Please remember that the get_sub_field function only works WITHIN a has_sub_field or have_rows loop.
You are correctly using a has_sub_field loop for the flexible content field, but are not using it again for the nested repeater field.
You need to change your inner loop to:
<?php if(get_sub_field("menu_items")): ?>
<?php while(has_sub_field("menu_items")): ?>
<li class="dontsplit">
<h3><?php echo get_sub_field("item_name"); ?>
<span>
<?php if(get_sub_field("price")): ?>
<?php foreach(get_sub_field("price") as $p): ?>
<?php echo $p['price_option']; ?>
<?php endforeach; ?>
<?php endif; ?>
</span>
</h3>
<p><?php echo get_sub_field("item_description"); ?></p>
<?php endforeach; ?>
</li>
<?php endif; ?>
Hope that helps.
Thanks
E
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.