Do you want to get top-level categories / taxonomy? The trick is to have
hide_empty=0 in your snippet. In this article, we’ll show you how to list top-level categories / taxonomy in WordPress.
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
<?php $args = array( 'type' => 'post', 'orderby' => 'term_group', 'hide_empty' => 0, 'hierarchical' => 0, 'parent' => 0, 'taxonomy' => '..if you are using a taxonomy instead of a category' ); get_categories( $args ); ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.