Try to use child_of
at your second foreach, see the documentation.
child_of
(integer) Get all descendents of this term. Default is 0. Note: the difference between child_of and parent is that where parent only gets direct children of the parent term (ie: 1 level down), child_of gets all descendants (as many levels as are available)
So in your case your second foreach will look like this:
<?php foreach( get_terms( 'wpsc_product_category', array( 'hide_empty' => false, 'child_of' => $parent_term->term_id ) ) as $child_term ) { ?>
You can use the returning value parent
in a conditional statement to detect on what “level” the term is. Of course you can do this also with one foreach.
Related Posts:
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- get the taxonomies terms associated with users
- Get list of taxonomies associated with users
- query_posts that have custom taxonomy and limiting what shows based on the taxonomy
- Taxonomy archive template that shows posts from more than one taxonomy
- How to get the term description in a taxonomy term archive query?
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- Custom taxonomy – query returns an error
- How to perform a search inside a specific taxonomy category
- Retrieve posts by term id custom query
- How to add images to taxonomies?
- Can you add the visual editor to the description field for custom taxonomies?
- Check if a post has any term in this custom taxonomy?
- Custom taxonomy hide meta box but show in menu
- Is there a way to disable a term rather than deleting it?
- Modify Term Update Redirection
- Check if current term is a child of another term
- get_terms() doesn’t return empty terms even though hide_empty is false
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Remove Category description textarea
- Archive template for taxonomy terms
- How can I set up a category “overview” page?
- Sort posts by number of matched terms
- Query multiple taxonomy in Custom Post Type
- Possible to register multiple custom taxonomies in one function?
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Function to limit the number of posts in taxonomy.php
- User role permissions based on taxonomies
- WP Query with custom taxonomy
- How to prevent posts duplicating when viewing a custom taxonomy term
- How to display custom taxonomy in multiple columns?
- get_the_terms() to show all custom taxonomies
- Custom taxonomies making WP very slow – Way to fix?
- Removing the “Popular Terms” area from the Taxonomy Edit Screen in the Admin Area
- Sorting taxonomy columns by meta value numeric
- Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]
- Get Taxonmy Term ID For Current Post
- Custom taxonomy query not working with switch_to_blog
- ACF vs Taxonomies
- Reverse traversing taxonomy based on term_id
- Get Current Custom Taxonomy ID by Post ID
- Taxonomy archive showing no results
- I used the Tax-meta-class by bainternet but i still can’t get it to display any of the results.
- Autogenerate Front End Form Field With jQuery
- Changing taxonomy term by slug (wp_update_term)
- Taxonomies on custom taxonomies
- How to join result of different taxonomies?
- How to add Post Format Taxonomy Archive page in the menu?
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- How to get all taxonomies which can be added in menu?
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- woocommerce custom product category template
- Replace taxonomy permalinks
- Custom Taxonomy Term Archive Page Template that Filters 2 or more Taxonomies
- Rewrite Rules returning wrong data
- WordPress Custom post query sorting does not work
- List related terms + taxonomies
- Create custom taxonomy and Display in metabox dropdown
- How to create a custom taxonomy using a shortcode?
- Override Taxonomy Template
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Filter through custom taxonomy with an array of taxonomy IDs
- Several taxonomy query (like filter)
- Custom taxonomy query showing more than 4 posts
- Taxonomy Overview Page?
- Order taxonomy terms wordpress
- Unable to get the Parent Custom Taxonomy Terms
- Unsetting post_tag taxonomy breaks term description for other taxonomies
- Taxonomies on Pages with Custom Formatting
- Query Multiple Custom Taxonomies
- Why do my quick edits for custom taxonomies not show on the post frontend?
- Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
- Tracking the name of a custom taxonomy
- new custom filed not showing in taxonomy
- Custom Taxonomies Archive Page 404
- How to replace custom post type with custom taxonmy in permalinks
- WP_Query for custom taxonomies showing posts from non-specified terms?
- How To Create Dynamic Permalink To Custom Taxonomy List of Current Posts?
- Dropdown (with onChange) with custom taxonomies
- ACF Custom field not showing in Timber Taxonomy page
- How to get a terms and posts associated with another term?
- Displaying subcategories and then posts in taxonomy template
- WP Query : strange behaviour with multiple no-hierarchical tax
- How to use two same taxonomy in same post differently?
- Sort Taxonomy List by Custom Values
- Query pages by child term
- Display taxonomy term slugs
- How to display custom taxonomy
- Taxonomy term breadcrumb; how?
- add custom fields in custom taxonomy meta box in wordpress-3.5.2
- How to permanently delete a taxonomy
- Advanced AND tax_query in sidebar with 2 taxonomies
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Get custom taxonomy term url on archive page
- Custom Taxonomy Template Variables Available?
- Display woocommerce product_cat child terms with thumbnails
- Adding new terms to custom taxonomy
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?