Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lincolnlemos/95d8c7288261234202bcb0881cc9d97c to your computer and use it in GitHub Desktop.
Save lincolnlemos/95d8c7288261234202bcb0881cc9d97c to your computer and use it in GitHub Desktop.
bootstrap collapse accordion with ACF repeater loop.php
<?php if( have_rows('collapse') ): ?>
<div id="accordion" role="tablist">
<?php $i=1; while ( have_rows('collapse') ) : the_row(); ?>
<div class="card">
<div class="card-header" role="tab" id="heading-<?php echo $i; ?>">
<h5 class="mb-0">
<a data-toggle="collapse" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('title'); ?>
</a>
</h5>
</div>
<div id="collapse-<?php echo $i; ?>" class="collapse <?php if ($i==1) { echo 'show'; } ?>" role="tabpanel" data-parent="#accordion" aria-labelledby="heading-<?php echo $i; ?>">
<div class="card-body">
<?php the_sub_field('body'); ?>
</div>
</div>
</div>
<?php $i++; endwhile; ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment