Home › Forums › Add-ons › Flexible Content Field › Two Dynamic Bootstrap Accordions › Reply To: Two Dynamic Bootstrap Accordions
A example using bootstrap accordion example from here https://getbootstrap.com/docs/4.3/components/collapse/
if (have_rows('flex-field')) {
$accord_count = 0;
while (have_rows('flex-field')) {
the_row();
if (get_row_layout() == 'accordion') {
if (have_rows('dropdown_area')) {
$row_count = 0;
$accord_count++;
?>
<div class="accordion" id="accordionExample<?php echo $accord_count; ?>">
<?php
while (have_rows('dropdown_area')) {
the_row();
$row_count++;
?>
<div class="card">
<div class="card-header" id="heading-<?php echo $accord_count; ?>-<?php echo $row_count; ?>">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapse-<?php
echo $accord_count; ?>-<?php echo $row_count;
?>" aria-expanded="<?php
if ($row_count == 1) {
echo 'true';
} else {
echo 'false';
}
?>" aria-controls="collapse-<?php
echo $accord_count; ?>-<?php echo $row_count; ?>">
Collapsible Group Item #1
</button>
</h2>
</div>
<div id="collapse-<?php echo $accord_count; ?>-<?php echo $row_count;
?>" class="collapse<?php
if ($row_count == 1) {
echo ' show';
}
?>" aria-labelledby="heading-<?php echo $accord_count; ?>-<?php echo $row_count;
?>" data-parent="#accordionExample<?php echo $accord_count; ?>">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<?php
} // end while have_rows('dropdown_area')
?>
</div>
<?php
} // end if have_rows('dropdown_area')
} // end if accordion
} // end while have_rows('flex-field')
} // end if have_rows('flex-field')
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.