I have a custom post type “apis”. This post type has a custom taxonomy “api_category” which has categories and subcategories.
What I need to do is get an array of all the categories in this custom taxonomy so that I can loop through them and then loop through their subcategories so I can display the custom posts grouped by category and then sub-category.
I have tried the_terms() and get_the_terms() but I must be doing it wrong.
In the past, I would do this when there was a parent category and all the categories and subcategories were children of this one category:
<?php $cat_id = 42; ?>
array( ‘parent’ => $cat_id )
foreach ( $child_categories as $child ) : ?>
<!– category row –>
<div class=”row w-100 category-row”>
<!– category title –>
<h1><?php echo $child->cat_name; ?></h1>
… etc …
But I’m trying now just to do it from the post type not from a parent category.
Is this even possible?