Home Forums Add-ons Repeater Field Multiple Bootstrap accordions with repeater field Reply To: Multiple Bootstrap accordions with repeater field

  • And here is my code for Bootstrap 4.

    I change the IDs name (#accordion) because I want to use multiple accordions on one page.

    <?php if( have_rows('_accordion_zeile') ): $accordion++; ?>
    <div id="accordion<?php echo $accordion; ?>">
    <?php while ( have_rows('_accordion_zeile') ) : the_row(); $collapse++; ?>
    	<div class="card">
    		<div class="card-header" id="heading<?php echo $collapse; ?>">
    			<h5 class="mb-0">
    			<button class="btn btn-link" data-toggle="collapse" data-target="#collapse<?php echo $collapse; ?>" aria-expanded="true" aria-controls="collapse<?php echo $collapse; ?>">
    				<?php the_sub_field("_accordion_titel"); ?>
    		<div id="collapse<?php echo $collapse; ?>" class="collapse" aria-labelledby="heading<?php echo $collapse; ?>" data-parent="#accordion<?php echo $accordion; ?>">
    			<div class="card-body">
    				<?php the_sub_field("_accordion_inhalt"); ?>
    <?php endwhile; ?>
    <?php endif; ?>