I have custom post type "product" and taxonomy is "product_cat". There are two child terms -Music and videos. Under Music i have two more child terms albums and single. Now when i go to music category i want to get all the child terms of the music. I am using the following code
<?php $page_id = get_the_id(); ?>
<?php $cat_terms = wp_get_object_terms( $page_id, 'product_cat' ); ?>
<pre><?php var_dump($cat_terms); ?></pre>
<?php foreach ($cat_terms as $terms ) {?>
<?php $array = (array) $terms; ?>
<section id="engagement-rings">
<div class="container">
<div class="row">
<div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
<div class="display-rings">
<div class="heading-img text-center"><?php echo $array["name"]; ?></div>
<div class="engagement rings-list clearfix">
<ul class="list-unstyled clearfix">
<?php
$args = array( 'post_type'=>'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $array["name"],
)
)
);
$postslist = get_posts( $args );
?>
<?php foreach ($postslist as $post) : ?>
<?php $array1 = (array) $post; ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'shop_thumbnail' ); ?>
<li><a href=""><img src="<?php echo $image[0]; ?>" alt=""></a></li>
<?php endforeach; ?>
</ul>
<a href="#" class="view-all">View all</a>
</div>
</div>
</div>
</div>
</div>
</section>
<?php } ?>
But this is giving me the Music category and one child i.e albums . But i just want album and single .
Please help me out