Accordion panel not collapsing with shortcode in custom post type. I can not add 'collapse class' in the accordion. It may be the issue in this case.
jQuery(document).ready(function($){
$(".panel-group .panel:first-child .panel-heading").addClass("active");
$(".panel-group .panel:first-child .panel-collapse").addClass("in");
});
This is the function I have in functions.php of my theme:
function acordian_shortcode( $atts ) {
extract(shortcode_atts(array(
'count' => '3',
'id' => '1',
), $atts ) );
$query = new WP_Query( array(
'post_type' => 'accordian',
'posts_per_page' => $count,
) );
$list = '<div class="panel-group" id="accordion'.$id.'">';
while ( $query->have_posts() ) : $query->the_post();
$id = get_the_ID();
$promo_icon = get_post_meta($id, 'promo_icon', true);
$list .= '
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion'.$id.'" href="#collapse'.get_the_ID().'">
'.get_the_title().'
<i class="fa fa-angle-right pull-right"></i>
</a>
</h3>
</div>
<div id="collapse'.get_the_ID().'" class="panel-collapse collapse">
<div class="panel-body">
'.get_the_content().'
</div>
</div>
</div> ';
endwhile;
$list .= '</div>';
wp_reset_postdata();
return $list;
}
add_shortcode( 'accordian', 'acordian_shortcode' );