If I’m understanding you correctly get_term_children
does what you want.
$term_id = 2;
$tax_name="locations";
$term_child = get_term_children( $term_id, $tax_name );
Another possibility would be using get_categories, it has an child_of
, taxonomy
and depth
parameter – the documentation on wp_list_categories, which offers pretty much the same functionality, is better.
Related Posts:
- Custom Taxonomy and Tax_Query
- “tax_query” parameter not working with WP_Query
- Including all terms in wordpress tax_query
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- Advanced Tax Query
- why do drafts return as part of wp_query?
- tax_query shows no results if nothing is selected
- Improving WP_Query performance for multiple taxonomies
- Advanced Query Logic With Multiple Taxonomies
- Hiding taxonomies with no children WP_Query & tax_query
- Set tax_query conditionally with new WP_Query
- How to do a particular wp_query taxonomy search
- Custom arguments in WP_Query
- check if a taxnomy queried in $wp_query?
- Query custom taxonomy for category including children
- how to use tax_query to apply both terms or one if one is empty
- list all post who have mutual taxonomy as current taxonomy!
- tax_query showing no results
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to limit posts to 1 from each term with tax_query?
- wp_get_object_terms count on taxonomies within an category archive
- Complex Taxonomy scheme
- How do I exclude a custom taxonomy from the post loop
- WordPress tax_query “and” operator not functioning as desired
- Using WordPress to make a “Product Search” type navigation drilldown
- display posts with same taxonomy term
- pre_get_posts with tax_query causes empty result
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Custom archive page based on array of categories and tags
- wp query with multiple taxonomy?
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Page queried instead of a custom taxonomy
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- List taxonomy / category count showing list published posts only
- Excluding a custom taxonomy term breaks wp_get_post_terms
- get complex results set according to category structure
- Dynamically tax_query terms
- How can I display all post IDs from the taxonomy?
- Get ID and slug from taxonomy object
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- How do I sort posts by custom taxonomy?
- Custom taxonomies making WP very slow – Way to fix?
- Query Custom Post Type Order By Taxonomy Field
- Get Taxonmy Term ID For Current Post
- Display sub categories and their data of a taxonomy
- Is it possible to get all term items from a custom taxonomy regardless of post attachment status?
- Changing stylesheet depending on custom taxonomy terms
- cannot get multiple loops using tax_query
- Taxonomy archive showing no results
- Get posts by term slug only
- Selecting all posts from the children of a particular parent taxonomy
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Add Custom Taxonomy for Blog Meta Info
- Getting associated taxonomies
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- querying posts by custom taxonomy terms right from a querystring based URL
- tax_query not working in template
- Custom taxonomy.php not working
- tax_query not working
- When filtering query on custom taxonomy; main menu dissapears
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- WP_Query parameter conflict
- Problem with wordpress pagination
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- Show only the sub-categories (and their content) of the current custom taxonomy with ‘taxonomy.php’
- Using Advanced Custom Fields Relationship Field to select a taxonomy term
- how to access the $query variable inside taxonomy-xxx.php template file?
- passing moree than one value of slugs in taxonomy using variable
- Tax_Query using WP_Query not working
- How to get related taxonomies based on a category with mysql query?
- custom post type and a “sticky” position taxonomy
- wp_query with meta_query and tax_query
- Tax-query on taxonomy doesn´t work
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- WP Query tax_query not returning posts
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- WordPress Multiple Taxonomy Query
- How can I get all the posts that are related with a specific taxonomy term?
- How to combine nested tax_query logic with other nested query logic?
- tax_query not working for taxonomy slug
- Custom query for tag and custom tag from 2 post type
- List active taxonomy terms
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- List posts of terms but exclude one term
- How do you search for a post by custom taxonomy?
- How do you move custom fields to custom taxonomies using WP Queries
- Order posts with custom taxonomy array
- Adding a query var to taxonomy term archive – gets redirected to the other taxonomy archive page
- WordPress Taxonomy Menu
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Get taxonomy image for Toolset custom taxonomy through Toolset Views Shortcode
- Hook to filter based on form value and insert term
- Querying posts globally based on custom taxonomy with its own taxonomymeta table
- Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms