Hi I'm new to programming and new to wordpress development.
I'm trying to create a testimonial page, with custom post tipes using sub categories. The idea is to have 4 categories of testimonials. And have a loop for each category. For this I am using the bootstrap 4 accordion. Then, when the user clicks on a certain category, the post loop for that category is displayed.
I've already been able to do the foreach to display the menu of the 4 categories. But I'm not able to structure the lopps within each category.
Follow the code:
<!-- Display the menu of categories, essa parte funciona OK -->
<?php
$catList = get_categories(
array(
'child_of' => 103,
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => '0'
) );
?>
<div class="accordion" id="accordionExample">
<?php $c = 1 ?>
<?php foreach($catList as $catItem) : ?>
<div class="card">
<div class="card-header" id="<?php echo $catItem->slug?>-tab">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#<?php echo $catItem->slug?>" aria-expanded="<?php echo ($c == 2)?'true':'false'; ?>" aria-controls="<?php echo $catItem->slug?>">
<?php echo $catItem->name?>
</button>
</h5>
</div>
</div>
<?php $c++ ?>
<?php endforeach ?>
<!-- End of Display the menu of categories -->
The point is to make the loops of each category I'm doing this:
<!-- Aqui o loop para cada categoria, Essa parte nao funciona -->
<?php $c = 1 ?>
<?php foreach($catList as $catItem) : ?>
<?php
$argsPosts = array(
'post_type' => 'depoimentos',
'posts_per_page' => 10,
'post__not_in' => get_option( 'sticky_posts' ),
'cat' => $catItem->cat_ID
);
?>
<?php $bladeQuery = new WP_Query($argsPosts); ?><?php if($bladeQuery->have_posts()) : ?><?php while ($bladeQuery->have_posts()) : ?><?php $bladeQuery->the_post(); ?>
<div id="<?php echo $catItem->slug?>" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body">
HEAR THE CONTENT OF EACH TESTIMONIALS
</div>
</div>
</div>
<?php endwhile; ?><?php endif; ?><?php wp_reset_postdata(); ?><!-- end query -->
<?php $c++ ?>
<?php endforeach ?>
</div>
Can anyone help me? Thanks!