I managed to answer this question myself by adding get_queried_object()->term_id;
instead of the taxonomy terms ID. It now outputs all the grandchild taxonomy terms for the current taxonomy term.
Here is my updated working code:
$term_id = get_queried_object()->term_id;
$taxonomy_name="product_range";
$term_children = get_term_children( $term_id, $taxonomy_name );
echo '<ul>';
foreach ( $term_children as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>';
}
echo '</ul>';
Related Posts:
- Query Multiple Taxominies Across Multiple Post type’s
- How to Filter custom post type by taxonomy?
- Full Custom Post Type List Organised by two Taxonomies
- Custom select query for taxonomies that have posts categorized in another taxonomy
- I have custom post type with custom taxonomy. But not found the taxonomy page..
- Group Custom post type in a taxonomy page by its child taxomony
- “Menu order” being ignored when querying posts from a parent taxonomy with “include_children” set to true
- How to get post count of specific taxonomy that have store name & category
- tax_query not working?
- How to show post which has the specific taxonomy terms?
- How to get all taxonomies of a post type?
- Efficient Taxonomy Intersection
- Custom taxonomy not showing up when adding a new custom post type
- How do I list custom taxonomy terms without the links?
- How to list custom taxonomy categories?
- Custom Taxonomy Template Post List with Sort Order
- The Operator “NOT IN” Does Not Work In tax_query
- How to list all categories and tags in a page?
- Create an archive page for custom taxonomies
- Order posts by (hierarchical custom) taxonomy terms and term children
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Group Custom post type in a page by its taxomony tag
- How do I list terms of a custom taxonomy at i.e. domain.com/brands/
- Taxonomy posts on Archive page
- Count number of posts which exist in 2 taxonomies?
- Taxonomy-{taxnonomy}.php is not working
- Display taxonomy term only if there’s a value
- Get list of terms of current taxonomy archive for another taxonomy
- Associate Taxonomies Across Post Types
- Show Post Count of a Category
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Relationship between two taxonomies and a custom post type [closed]
- Menu Multiple Taxonomies
- How to make a custom taxonomy selectable in post publish area?
- Problem with custom post types, taxonomy and permalinks
- How to create new category for custom post type?
- Fetch taxonomies by custom post type id array
- Custom page template for category taxonomy
- How do I get array of types associated with a taxonomy?
- Display all posts in main category and 1 subcategory
- wp_get_post_terms on custom post type with custom taxonomies returning an empty array
- Tax query not producing any results
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- limit value taxonomy based on previous taxonomy value wordpress
- Using meta_query and tax_query at the same time
- How to make custom taxonomy into drop down select in a custom metabox
- How do I share categories across multiple post types?
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Taxonomy in URL
- How to display Related Posts based on number of taxonomy terms matched
- tax_query not working in template
- How to Set Taxonomy Object Description?
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Variable not working in WP_Query
- WP_query – Filter by tax_query and meta_query using multiple select
- Hide meta box for everything BUT a certain custom post type
- WP_Query parameter conflict
- Alphabetically sort a taxonomy.php template by post title
- Custom Post Types not queried in Custom Taxonomy archives or Native archives
- Show Taxonomies with admin area for custom post type?
- Use the custom post type archive for taxonomies?
- Taxonomy template page not working
- tax_query (if the terms are empty)
- Changing CPT slug and taxonomy already registered in parent theme
- Copy/Move selected taxonomy terms to another taxonomy for posts
- Running a custom query inside another cpt single and trying to grab a variable
- Get posts by category name
- Grab all Custom Posts by multiple taxonomies and terms
- Query Custom Post Type by Taxonomy
- Query all posts under one taxonomy? Why is my code not working?
- custom post type and a “sticky” position taxonomy
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- How to order taxonomy terms by most recent post?
- Custom taxonomy returns 404 even with saving permalinks
- Create custom post type categories
- Change custom post taxonomy values from front-end
- Set a Default CPT taxonomy by taxonomy id
- List all posts associated under custom taxonomy
- How to transfer categories (default) to custom taxonomy?
- How can I get the last 5 element of this tax query?
- Add other all taxonomies as meta boxes to custom post type
- How to get post type archive category title
- Pages of my taxonomy terms are showing all posts
- Custom post type category link + add to menu
- WP Query tax_query not returning posts
- Single taxonomy for different custom post types
- Filter Term By Parent Term – Custom Post Type
- Best approach to allow front-end display of posts’ reviewers?
- Custom Post Type and Taxonomies, creating the corresponding template file and loop the data
- How to create TEMPLATES for TAXONOMIES? What I have to change in this code?
- List all posts from custom post type by taxonomy
- Displaying taxonomy icon outside archive page
- Archive templates based on taxonomies
- See the process of creating a taxonomy and tell me where I made a mistake
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Taxonomy listing issue – does not display how I would like
- Taxonomy Archive URL + Template