// This is the coding for getting the subcategory and subcategory
$args = array ( 'number' => $number, 'orderby' => 'title', 'order' => 'ASC', 'hide_empty' => false, 'include' => array(11,281,28,51,99,93,33,55,107,20), 'exclude' => array(32,29), ); $product_categories = get_terms( 'product_cat', $args ); // echo '<pre>'; // print_r($product_categories); // echo '</pre>'; foreach($product_categories as $data): if($data->slug = 'cooking') { $child_arg = array('hide_empty'=>false,'parent'=>$data->term_id,'exclude'=>array(32,29)); } else { $child_arg = array('hide_empty'=>false,'parent'=>$data->term_id); } $child_terms = get_terms('product_cat',$child_arg); // echo "<pre>"; // print_r($child_terms); // echo "</pre>"; foreach($child_terms as $data1): if($data1->slug = 'cooking') { $sub_child_arg = array('hide_empty'=>false,'parent'=>$data1->term_id,'exclude'=>array(32,29)); } else { $sub_child_arg = array('hide_empty'=>false,'parent'=>$data1->term_id); } $sub_child_terms = get_terms('product_cat',$sub_child_arg); // echo "<pre>"; // print_r($sub_child_terms); // echo "</pre>"; endforeach; endforeach; ?>
source share