You’ll probably have to run a cycle using get_terms() paired with the ‘parent’ attribute.
$args = array( 'parent' => 0 );
$parents = get_terms( array( 'custom-tax' ), $args );
foreach ( $parents as $parent ) {
echo $parent->name;
$args['parent'] = $parent->term_id;
if ( $children = get_terms( array( 'custom-tax' ), $args ) ) {
foreach ( $children as $child ) {
echo $child->name;
}
}
}
You may be able to rewrite the “if ( $children…” into a while loop if you need more recursion than that.
Related Posts:
- Get the the top-level parent of a custom taxonomy term
- get_terms – only top level
- Custom taxonomy terms not showing as list Gutenberg Editor
- How to only list the child terms of a taxonomy and not their parents?
- Order get_terms using a Custom Field
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
- get_terms() returns an empty array
- Scheduling posts to update once per day with wp_cron
- wp_options table value
- Custom Taxonomy Meta Admin Column
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- How to assign default taxonomy to pages on ‘save_post’?
- Count number of post in Taxonomy?
- wp_query orderby title and meta key value (WP3.1)
- custom taxonomies on permalink
- Manipulating cookie on specific taxonomy archive page
- Landing in 404 Page on Navigating to Custom Taxonomy Archive
- Get main term from a sub term in Woocommerce
- Permalinks for quote authors
- Category page and edit post page with this category very slow
- Using a loop to display terms associated with a post
- Custom Taxonomy tree view not showing correctly in backend
- In a loop of custom post type, display first custom taxonomy term
- Generic taxonomy-term template page
- Taxonomy page template changing when using query variables
- How to add taxonomy to Users menu in admin?
- Category page for custom-taxonomy shows 404 when using custom permalink structure
- How to count the number of terms in a taxonomy
- All posts are still shown when adding category argument to query
- How to add autocomplete to custom taxonomy for CPT
- List subcategory on taxonomy term page
- Current category link filter
- How to Put Custom Taxanomy Meta Box in Main Column
- Hook to change Custom Tag Taxonomy Links?
- Using wp_list_categories to show more than one custom taxonomy
- Show all posts without a custom taxonomy
- Woocommerce product search result layout page
- Sorting Tags by Slug Value
- How do I taxonomy terms based on terms they are used alongside?
- Search functionality in ‘taxonomy postbox’ on edit post page
- How can I populate a select element with terms from a custom taxonomy and filter post results?
- How do I list the pages of a custom taxonomy?
- Change the permalink URL to include a taxonomy term
- How to limit the number of users who can be added to a user custom taxonomy?
- Get Custom Taxonomy Title by Spesific Sub Category via fputcsv
- Why does a new taxonomy term get created when I assign an existing term to a post?
- Display only child terms of a specific parent term of a custom taxonomy, for each custom post
- Add Image Uploader In Admin Panel
- Are exclusive taxonomy terms possible?
- How do I create a permalink structure with 2 taxonomies
- How to use multiple archive templates for a taxonomy?
- Some custom taxonomy child terms not showing in admin. Caching problem?
- Custom Taxonomy Query
- Pass taxanomy parameters to next_post_link()?
- Clicking Add New button for custom taxonomy only moves element
- Proper use of wp_get_object_terms
- Permalink Problems
- Get Terms for Page
- tax_query: Don’t show posts with parent term when they have a corresponding child term applied
- Can’t get taxonomy ID for each post on archive page
- forward/redirect taxonomy archive of term to a page with same name
- How to add a date creation field when a custom taxonomy relationship is created?
- List custom taxonomies associated to an author’s posts
- Why can’t I access Custom Taxonomy metadata?
- Permalinks with custom taxonomies and regular categories
- WP_Query tax_query – Show results if child has parent X
- Singular custom taxonomy label
- Trash Bin for Categories?
- Display just the Post’s parent Category, not child
- Tree view wp-admin terms
- Retrieve the child terms by having the parent’s information
- How to add chained dropdown filter to a wordpress website
- How to get a taxonomy by a term slug?
- Get taxonomy link with post type slug prefix
- Change the Page Title of the Archive Page for Portfolio Tags
- Is it possible to sort the post based on a custom field?
- Why get_terms() behaves strangely when being called in admin (for use in meta box)?
- qtranslate-x problem with custom term description
- Custom Tax Archive of Parents Only?
- Switching from catalog to product category/subcategory
- ‘Post_tag’ taxonomy tags don’t link to existing posts in CMS
- Sorting terms individually for each post
- Looking for suggestions on creating simple database (Help!!)
- Display list of custom taxonomies from a custom post type ordered by their parent
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- get meta fields and taxonomy of any post type
- Custom taxonomy – query returns an error
- Change taxonomy of posts
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Update fields with post object and custom tax with wp_insert_post
- Get Posts with matching lowest taxonomies
- Can you orderby slug in a taxonomy archive page using WP_Query?
- Any way to make custom taxonomy field searchable?
- Select Custom Taxonomy from Theme Options
- Remove Tag Cloud Words from Custom Taxonomy
- Taxonomies starting with a hyphen (minus) to assign B.C. dates to a post
- Rewrite URL for a specific taxonomy [duplicate]
- Template hierarchy html with taxonomy in 6.2