Last active
December 3, 2019 14:39
-
-
Save omurphy27/97ab6b6b6eecdf1ecba4 to your computer and use it in GitHub Desktop.
bootstrap collapse accordion with ACF repeater loop.php
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_rows('faqs') ): ?> | |
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |
<?php $i=1; while ( have_rows('faqs') ) : the_row(); ?> | |
<div class="panel panel-default"> | |
<div class="panel-heading" role="tab" id="heading-<?php echo $i; ?>"> | |
<h2 class="panel-title"> | |
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne"> | |
<?php the_sub_field('question'); ?> | |
</a> | |
</h2> | |
</div> | |
<div id="collapse-<?php echo $i; ?>" class="panel-collapse collapse <?php if ($i==1) { echo 'in'; } ?>" role="tabpanel" aria-labelledby="heading-<?php echo $i; ?>"> | |
<div class="panel-body"> | |
<?php the_sub_field('answer'); ?> | |
</div> | |
</div> | |
</div> | |
<?php $i++; endwhile; ?> | |
</div> | |
<?php endif; ?> |
I am doing this inside of a loop, so that I have multiple accordions, using categories to fill each one in the repeater. Do I still use the $query and WP Loop around what you have?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for bootstrap 4 here
https://gist.github.com/lincolnlemos/95d8c7288261234202bcb0881cc9d97c