Home › Forums › Add-ons › Repeater Field › Unique ID for Repeater Field › Reply To: Unique ID for Repeater Field
Hey Dave,
What a coincidence seeing you here – ha!
The way to do that is check if it’s the first iteration of the while loop:
<div class="tabs">
<?php if(get_field('additional_content')): $i = 0; ?>
<?php while(has_sub_field('additional_content')): $i++; ?>
<input type="radio" name="tabs" id="tab<?php echo $i; ?>"<?php if($i == 0) { echo " checked"; };?> />
<label for="tab<?php echo $i; ?>" class="<?php the_sub_field('field_label'); ?>"><?php the_sub_field('extra_title'); ?></label>
<?php endwhile; ?>
<?php endif; ?>
<?php if(get_field('additional_content')): $i = 0; ?>
<?php while(has_sub_field('additional_content')): $i++; ?>
<div id="tab-content<?php echo $i; ?>" class="tab-content">
<?php the_sub_field('extra_content'); ?>
</div> <!-- #tab-content1 -->
<?php endwhile; ?>
<?php endif; ?>
</div>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.