Need Sub-category with main Category

Currently I used the following codes for get WooCommerce product categories. But, I need sub-categories too. Also what is the way to remove class=”label-0″ from select options?

if(isset($_REQUEST[‘product_cat’]) && !empty($_REQUEST[‘product_cat’])) {
} else {
$args = array(
‘show_option_all’ => esc_html__( ‘All Categories’, ‘woocommerce’ ),
‘orderby’ => ‘ID’,
‘hierarchical’ => 1,
‘class’ => ‘cat’,
‘echo’ => 1,
‘value_field’ => ‘slug’,
‘selected’ => $optsetlect
$args[‘taxonomy’] = ‘product_cat’;
$args[‘name’] = ‘product_cat’;
$args[‘class’] = ‘cate-dropdown hidden-xs’;

<select name=”product_cat” id=”product_cat” class=”cate-dropdown hidden-xs”>
<option value=”0″ selected=”selected”>All Categories</option>
<option class=”level-0″ value=”womens-fashion”>Women’s Fashion</option>
<option class=”level-0″ value=”mans-fashion”>Man’s Fashion</option>
<option class=”level-0″ value=”phones-accessories”>Phones &amp; Accessories</option>

Read more here:: Need Sub-category with main Category

Leave a Reply

Your email address will not be published. Required fields are marked *