Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save omurphy27/97ab6b6b6eecdf1ecba4 to your computer and use it in GitHub Desktop.
Save omurphy27/97ab6b6b6eecdf1ecba4 to your computer and use it in GitHub Desktop.
bootstrap collapse accordion with ACF repeater loop.php
<?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; ?>
@lincolnlemos
Copy link

@jerrylee
Copy link

jerrylee commented Mar 8, 2018

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