I am trying to show the woocommerce product child category for the corresponding parent category. I have entered the product is as following,Product Category details that I entered
I am using the following code segment that is display the parent category list,
<?php
$IDbyNAME = get_term_by('name', $parent_cat_NAME, 'product_cat');
$product_cat_ID = $IDbyNAME->term_id;
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => $product_cat_ID,
'taxonomy' => 'product_cat'
);
$categories = get_categories($args);
foreach ($categories as $category) {
echo $category->name;
}
?>
That is working well. Now I want to modify my code segment to display output is as following,
Album
English Songs
Modern Songs
Pop
Rock
How can i do it. Please help me to solve this. Thanks for advanced.