Skip to content

Instantly share code, notes, and snippets.

@softauthor
Last active September 8, 2021 20:34
Show Gist options
  • Save softauthor/c9e53b94248822eb4ba20e8447002931 to your computer and use it in GitHub Desktop.
Save softauthor/c9e53b94248822eb4ba20e8447002931 to your computer and use it in GitHub Desktop.
<?php
$par_args = array(
'parent' => 0
);
$parent_categories = get_categories($par_args);
foreach($parent_categories as $parent_category) {
echo '<h2 class="ui header">' . $parent_category->name . '</h2>';
$chi_args = array(
'child_of' => $parent_category->cat_ID
);
$children_categories = get_categories($chi_args);
foreach($children_categories as $children_category) {
echo '<li><a href="'. get_category_link($children_category->cat_ID) .'">' . $children_category->name . '</a></li>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment