Skip to content

Instantly share code, notes, and snippets.

@bacalj
Last active August 29, 2015 14:08
Show Gist options
  • Save bacalj/a1cf2c51473f1b4077ac to your computer and use it in GitHub Desktop.
Save bacalj/a1cf2c51473f1b4077ac to your computer and use it in GitHub Desktop.
set up a repeater field to end up in bootstrap tabs
<div id="main-container" class="section">
<div class="main-body container">
<div class="row">
<div class="post-content col-md-10">
<?php if (have_posts()) : while(have_posts()) :the_post();?>
<div class="post-single" id="post-<?php the_ID(); ?>">
<div class="post-body">
<?php the_content();
//if there are tabs - open up a tabset ul
if( get_field('tab') ) {
echo ('<ul class="nav nav-tabs" role="tablist">');
//loop to write each tab in the tabset
$tabCounter = 1;
while( has_sub_field('tab') ) {
$tabLink = '<a href ="#' . $tabCounter .'" role="tab" data-toggle="tab">';
$tabTitle = get_sub_field('tab_title');
if ($tabCounter == 1 ) {
echo ('<li class="active">' . $tabLink . $tabTitle . '</a></li>' );
}
else {
echo ('<li>' . $tabLink . $tabTitle . '</a></li>' );
}
$tabCounter ++;
}
echo ('</ul>');
echo ('<div class="tab-content">');
//loop again to write out the tab content
$divCounter = 1;
while( has_sub_field('tab') ) {
if ($divCounter == 1 ) {
$divId = '<div class="tab-pane fade in active" id="'. $divCounter . '">' ;
}
else {
$divId = '<div class="tab-pane fade" id="'. $divCounter . '">' ;
}
$mycontent = get_sub_field('tab_content');
echo ($divId . $mycontent . '</div>');
$divCounter ++;
}
echo ('</div>');
}
?>
</div>
</div>
<?php endwhile; endif; ?>
</div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment