Last active
May 22, 2018 23:03
-
-
Save bacalj/18dac320b5d32b249207 to your computer and use it in GitHub Desktop.
getting acf repeater into bootstrap tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (have_posts()) : while(have_posts()) :the_post();?> | |
<div class="post-single" id="post-<?php the_ID(); ?>"> | |
<div class="post-body"> | |
<!-- START CONTENT --> | |
<?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>'); | |
} | |
?> | |
<!-- END CONTENT --> | |
</div> | |
</div> | |
<?php endwhile; endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thank you's for posting this!