I have this page on my website - https://visitwinona.com/ask-a-local/
Where I'm calling all the categories of my custom post type faqs, I've implemented the bootstrap accordion, and it works but as I added a new category the last accordion opens a random one instead of the one it's meant to. I see that it's using the same ID for some reason but I'm unsure how to solve this,
<?php
/*
* Loop through Categories and Display Posts within
*/
$post_type = 'faqs';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( array( 'post_type' => $post_type
) );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) : ?>
<?php
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1, //show all posts
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term->slug,
)
)
);?>
<h2 style="margin-bottom: 20px;">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php the_ID(); ?>" aria-expanded="true" aria-controls="collapse-<?php the_ID(); ?>">
<?php echo $term->name; ?> +
</a>
</h2>
<div id="collapse-<?php the_ID(); ?>" class="panel-collapse collapse <?php if( $c == 1 ) echo 'in'; ?>" role="tabpanel" aria-labelledby="heading-<?php the_ID(); ?>">
<?php $localfaqs = new WP_Query($args);?>
<?php if ( $localfaqs->have_posts() ) : while ( $localfaqs->have_posts() ) : $localfaqs->the_post(); $c++; ?>
<div class="row">
<?php
$faqs = get_field('local');
if( $faqs ): ?>
<?php foreach( $faqs as $p ): // variable must NOT be called $post (IMPORTANT) ?>
<div class="col-md-half faq-circle">
<div class="celeb-circle-faq">
<a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_post_thumbnail( $p->ID ); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<div class="col-md-10 faq-link">
<a href="<?php the_permalink();?>">
<?php the_title();?>
</a>
</div>
</div>
<?php endwhile; endif; ?>
</div>
<?php endforeach;
endforeach; ?>
Any advice would be great,
Thanks!