Home › Forums › Add-ons › Repeater Field › Repeater to create bootstrap tabs? › Reply To: Repeater to create bootstrap tabs?
Thanks John.
Incase anyone is interested here is my code…
<?php
$rows = get_field('tab_test');
echo '<pre>';
var_dump( $rows );
echo '</pre>';
if (have_rows('tab_test')) {
echo'<ul class="nav nav-tabs" role="tablist">';
while(have_rows('tab_test')) { the_row();
$tab_button = get_sub_field('tab_button');
$tab_id = get_sub_field('tab_id');
echo' <li role="presentation"><a href="#'.$tab_id.'" aria-controls="'.$tab_button.'" role="tab" data-toggle="tab">';
// output sub field content
echo''.$tab_button.'';
echo'</a></li>';
}
echo'</ul>';
// reset the rows of the repeater
reset_rows();
echo'<div class="tab-content">';
// second loop of same rows
while(have_rows('tab_test')) { the_row();
$tab_button = get_sub_field('tab_button');
$tab_content = get_sub_field('tab_content');
$tab_id = get_sub_field('tab_id');
echo'<div role="tabpanel" class="tab-pane " id="'.$tab_id.'">';
// output sub field content
echo''. $tab_content.'';
echo'</div>';
}
echo'</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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.