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.
Instructions:
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.
If you liked this code snippet, please consider checking out our other articles on the site like: 62 best free WordPress blog themes or 7 best WordPress contact form plugins.
        
How would you get the 2nd level of the taxonomy?