Home › Forums › Add-ons › Repeater Field › Repeater Issue
I am using bootstrap tab:
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<?php if( get_field('repeater', 'option') ): ?>
<?php while( has_sub_field('repeater_subfield1', 'option') ): ?>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
<?php break; endwhile; ?>
<?php endif; ?>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">Home Text</div>
<div role="tabpanel" class="tab-pane" id="profile">
<?php while ( have_rows('repeater', 'option') ) : the_row(); ?>
<div class="col-sm-2 col-xs-6 color_showcase text-center">
<img src="<?php the_sub_field('repeater_subfield1'); ?>" alt="">
<?php the_sub_field('repeater_subfield2'); ?>
</div>
<?php endwhile; ?>
</div>
</div>
If Repeater sub fields are empty then there is no meaning of showing Profile Tab. All works well but if you have like 10 repeat fields, only 9 shows in tab content and 1 is already echoed by the first get_field code.
Am I clear ?
Hi @debendra
Sorry but you need to elaborate a bit ..
Where’s the issue? Or is it that you’re tying to do something but not succeeding?
Also, you’re using old repeater code for the first part with has_sub_fields
but then correct code in the second while loop. Why?
Hi Jonathan
I used old code for trying only, my problem is:
inside tab panel there are repeater subfields, if there are subfields it is fine to show the <li>
tab but if no repeater subfields then I don’t need to show this <li>
tab. (did you get me?).
I am doing everything fine, but I am not able to echo all repeater fields in tab-pane, the first one will be missing, the first one will be echoed on first condition in <li>
If you are not clear, I can send you wp-admin user and pass as well personally in your email.
Hi Jonathan
I have solved this, I am loving this ACF.
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
<?php if ( have_rows('repeater', 'option') ) {
while ( have_rows('repeater', 'option') ) : the_row();
$image = get_sub_field('repeater_subfield1', 'option' );
endwhile;
if($image) {
?>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
<?php } } ?>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">Home Text</div>
<div role="tabpanel" class="tab-pane" id="profile">
<?php while ( have_rows('repeater', 'option') ) : the_row(); ?>
<div class="col-sm-2 col-xs-6 color_showcase text-center">
<img src="<?php the_sub_field('repeater_subfield1'); ?>" alt="">
<?php the_sub_field('repeater_subfield2'); ?>
</div>
<?php endwhile; ?>
</div>
</div>
Hi @debendra
Great to hear!
The code looks solid. I also have a fondness for ACF 😉
Best of luck with your coding
The topic ‘Repeater Issue’ 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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.