Yapmak istediğimi yabancı forumlardan bulduğum kodlarla yaptım. Belki birisine lazım olur. Aşağıda
 <?php
$parent_cat_arg = array('hide_empty' => 1, 'parent' => 0, 'exclude' => '44,2547');
$parent_cat = get_terms('category',$parent_cat_arg);//category name
foreach ($parent_cat as $catVal) {
echo '<div class="headerbar"><a href="' . get_term_link( $catVal) . '">' . $catVal->name . '</a></div>';
    $child_arg = array( 'hide_empty' => false, 'parent' => $catVal->term_id );
    $child_cat = get_terms( 'category', $child_arg );

echo '<ul class="submenu">';
foreach( $child_cat as $child_term ) {
echo '<li><a href="' . get_term_link( $child_term) . '">' . $child_term->name . '</a></li>';
  }
    echo '</ul>';

}
?>

Bu koda şöyle bir fonksiyonu nasıl ekleriz. Sadece içine girilen ana kategorinin alt kategorileri listelensin.