Displaying Categories and Sub Categories

You can achieve categories and sub-categories this way.

<?php 

$list_categories = get_categories( $args );
echo "<div class="container">";
echo "<div class="productsubmenu">";
echo "<ul>";

foreach ($list_categories as $cat)
{           

if($cat->category_parent == 0)
{
$category_id = $cat->term_id;

echo '<li class="parent '.$my.' "><a href="'.get_term_link( $cat ) . '">'.$cat->name.'</a>';


$args2 = array(
'taxonomy' => $taxonomy,
'child_of' => 0,
'parent' => $category_id,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty

);
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 1,
'parent' => $parent_cat_ID,
'taxonomy' => 'product_cat'
);
$subcats = get_categories($args2);
echo '<ul class="wooc_sclist">';

foreach ($subcats as $sc) { 
$link = get_term_link( $sc->slug, $sc->taxonomy );
echo '<li class="" ><a href="'. $link .'">'.$sc->name.'</a></li>';
}


}
echo '</ul>';
echo "</li>";
}

?>

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş