Home › Forums › Add-ons › Repeater Field › Need to iterate/rewind over repeater field set twice
I am trying to implement tabs in Foundation
http://foundation.zurb.com/docs/components/tabs.html
I would prefer to loop once over the ‘service_title’ to make the titles (i.e. ‘tab 1’) in the ul li the first time around, and then rewind the post’s subfield loop, or whatever you’d call this, to place ‘service_image’ and ‘service_body’ in a lower content div. I suppose I can put everything in a keyed array during the first loop but I would prefer to do this ‘the right way’. Is there a way to reset the counter which is incremented upon every the_row() ? Kind of like a rewind_post but within *one* post.
<ul class="tabs" data-tab>
<li class="tab-title active"><a href="#panel1">Tab 1</a></li>
<li class="tab-title"><a href="#panel2">Tab 2</a></li>
<li class="tab-title"><a href="#panel3">Tab 3</a></li>
<li class="tab-title"><a href="#panel4">Tab 4</a></li>
</ul>
<div class="tabs-content">
<div class="content active" id="panel1">
<p>This is the first panel of the basic tab example. You can place all sorts of content here including a grid.</p>
</div>
<div class="content" id="panel2">
<p>This is the second panel of the basic tab example. This is the second panel of the basic tab example.</p>
</div>
<div class="content" id="panel3">
<p>This is the third panel of the basic tab example. This is the third panel of the basic tab example.</p>
</div>
<div class="content" id="panel4">
<p>This is the fourth panel of the basic tab example. This is the fourth panel of the basic tab example.</p>
</div>
</div>
Actually, there is a function, it appears to be undocumented.
add reset_rows()
after the while loop.
Ah thanks, I will remember that for the future. I just iterated over everything and saved it in arrays, got it working ‘the old fashioned way’. Seems like this should *really* be in documentation because it definitely isn’t!
I dig around in the ACF code quite frequently when I’m trying to figure out if I can do something. Elliot is the only developer working on ACF and the documentation, it’s not surprising that the documentation misses a few of the finer details.
The topic ‘Need to iterate/rewind over repeater field set twice’ is closed to new replies.
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.