Hi John!
I got this to work 100%, I had to make a few changes but now works great
this is the code in case someone needs it,
<div>
<?php
if( have_rows('menu_sections') ): ?>
<ul class="nav nav-tabs" id="" role="tablist">
<?php $i=0; while ( have_rows('menu_sections') ) : the_row(); ?>
<?php
$string = sanitize_title( get_sub_field('section_title') );
?>
<li role="presentation" <?php if ($i==0) { ?>class="active"<?php } ?> >
<a>" aria-controls="<?php echo $string ?>" role="tab" data-toggle="tab"><?php the_sub_field('section_title'); ?></a>
</li>
<?php $i++; endwhile; ?>
</ul>
<div class="tab-content">
<?php $i=0; while ( have_rows('menu_sections') ) : the_row(); ?>
<?php
$string = sanitize_title( get_sub_field('section_title') );
?>
<div role="tabpanel" class="tab-pane text-left fade <?php if ($i==0) { ?>in active<?php } ?>" id="<?php echo $string; ?>">
<?php
while (have_rows('section_items')) {
the_row();
// Display each item as a list
?>
<ul>
<li class="list-unstyled"><?php the_sub_field('dish_name'); ?></li>
<li class="list-unstyled"><?php the_sub_field('dish_description'); ?></li>
<li class="list-unstyled">$<?php the_sub_field('dish_price'); ?></li>
</ul>
<?php
} // end while have rows section_items
?>
</div>
<?php $i++; endwhile; ?>
</div>
<?php endif; ?>
</div>
Thanks for all your help.
Thanks John,
Yes everything works great, I will look into Bootstrap and let you know as soon as I find the problem.
Thank you so much!
Thanks John!
Yes I’ve seen the changes and the only thing I noticed is that when you put one item on each tab works fine but if you add more items to one of them the following one won’t work.
I think its got something to do with the ID tag.
I appreciate all your help.
Thanks very much,
I did everything as you specified and got these results,
Thanks,
I changed the code to this,
<div>
<!-- Check for parent repeater row -->
<?php if( have_rows('menu_sections') ): ?>
<ul class="nav nav-tabs" role="tablist">
<?php $row = 1; // number rows ?>
<?php // Step 1: Loop through rows, first displaying tab titles
while( have_rows('menu_sections') ): the_row();
// ?>
<li role="presentation" class="list-unstyled<?php if($row == 1) {echo 'active';}?>">
<a
href="#<?php echo $row; ?>"
role="tab"
data-toggle="tab"
>
<?php the_sub_field('section_title'); ?>
</a>
</li>
</ul>
<?php if( have_rows('section_items') ): ?>
<div class="tab-content">
<?php $row = 1; // number rows ?>
<?php // Step 2: Loop through rows, now displaying tab contents
while( have_rows('section_items') ): the_row(); ?>
<?php // Display each item as a list ?>
<div class="tab-pane <?php if($row == 1) {echo 'active';}?>" id="<?php echo $row; ?>">
<ul>
<li class="list-unstyled"><?php the_sub_field('dish_name'); ?></li>
<li class="list-unstyled"><?php the_sub_field('dish_description'); ?></li>
<li class="list-unstyled"><?php the_sub_field('dish_price'); ?>
</ul>
</div>
<?php $row++; endwhile; // (have_rows('section_items') ):?>
</div>
<?php endif; // (have_rows('section_items') ): ?>
<?php $row++; endwhile; // (have_rows('menu_sections') ):?>
<?php endif; // (have_rows('menu_sections') ): ?>
</div>
Now it does show the tab content but like this,
As you can see the second tab is not showing properly,
I tried to reset the rows but it didn’t work,
Am I missing something?
Thanks for all your help.
Yes I do have two different repeaters the following is the structure of the fields,
Thank again,
Thanks for your quick response I appreciate the time you’re taking to help out
I tried reset_rows
as you can see in the above code but still didn’t work,
Do you have any other suggestions?
Thanks,
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.