How to Show Parent with child Categories

<?php

$args = array(
‘orderby’       => ‘term_order’,
‘order’         => ‘ASC’,
‘hide_empty’    => true,
‘show_count’ => true,
‘parent’         => 0);
$terms = get_terms(‘eventcategory’, $args);
if(!empty($terms)):
foreach($terms as $cat):
echo ‘<h6>’ . $cat->name . ‘</h6><ul class=”large-block-grid-1 medium-block-grid-1 small-block-grid-1″>’;
$args2 = array(
‘orderby’       => ‘term_order’,
‘order’         => ‘ASC’,
‘show_count’ => true,
‘hide_empty’    => true,
‘parent’         => $cat->term_id);
$terms2 = get_terms(‘eventcategory’, $args2);

foreach($terms2  as $child_cat):
echo ‘<li><a href=”‘.get_term_link( $child_cat->slug, $child_cat->taxonomy).'”>’.ucfirst($child_cat->name).'</a></li>’;
endforeach;
echo “</ul>”;
endforeach;
endif;

?>

Advertisements