I am trying to create tabs using the Foundations framework, outputting posts from a custom post type called testimonial and filtering them through their assigned custom category called filed-under. What am I doing wrong in my loop?
What I Have Working
- Category tabs appear when new categories are created
What is Not Working
- The posts aren't appearing in the tabbed content area
Link to Demo http://staging-newmummycompanyca.temp312.kinsta.cloud/testimonials/
Code
// TABBED HEADERS
echo '<ul class="tabs" data-tabs id="example-tabs">';
echo '<li class="tabs-title is-active link-no-style">';
echo '<a href="#all" aria-selected="true">All</a>';
echo '</li>';
$args = array(
'hide_empty'=> 1,
'orderby' => 'name',
'order' => 'ASC',
'post_type' => 'testimonial',
'taxonomy' => 'filed-under',
);
$categories = get_categories($args);
foreach($categories as $category) {
echo
'<li class="tabs-title link-no-style">
<a href="#' . $category->slug . '" aria-selected="true" role="tab" data-toggle="tab">
'.$category->name.'
</a>
</li>';
}
echo '</ul>';
// TABBED CONTENT
echo '<div class="tabs-content" data-tabs-content="example-tabs">';
echo '<div class="tabs-panel is-active" id="' . $category->slug .'">';
echo '<ul class="accordion" data-accordion data-allow-all-closed="true">';
foreach($categories as $category) {
$the_query = new WP_Query(array(
'post_type' => 'testimonial',
'post_status' => ' publish',
'category_name' => $category->slug,
));
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<li class="accordion-item" data-accordion-item>';
echo '<a href="#" class="accordion-title">';
the_title();
echo '</a>';
echo '<div class="accordion-content" data-tab-content>';
echo the_field('testimonial');
echo '</div>';
echo '</li>';
endwhile;
wp_reset_postdata();
}
echo '</ul></div></div>';
?>
[1]: http://staging-newmummycompanyca.temp312.kinsta.cloud/testimonials/