You can use get_terms()
to get an array of child slugs:
/**
* Get child term slugs from given term parent
*
* @param Integer $parent_id ( Parent Term ID )
* @param String $taxonomy ( Taxonomy Slug )
*
* @return Array( $term_id => $child_slug )
*/
function get_child_slugs( $parent_id = 0, $taxonomy = 'category' ) {
return get_terms( array(
'taxonomy' => $taxonomy,
'parent' => $parent_id,
'fields' => 'id=>slug',
) );
}
This should return a simple array of array( $term_id => $term_slug )
assuming a valid parent term ID and valid taxonomy is supplied.
Related Posts:
- wp_list_categories: order by term order?
- Difference between get_category, get_term_by and get_categories
- get_terms from registered taxonomies not working
- Display custom taxonomy on single post
- Group child category IDs based on their parent category
- Getting all categories even with no products under it?
- Add HTML to Term Description
- List posts by their custom taxonomy term, with a condition
- I can get posts in all categories. But I want to get the custom post type I created
- how to show all categories by get_terms
- Is there any WordPress way to get all categories for some selected posts?
- get_terms vs. get_categories: does it matter?
- Woocommerce get category image full size
- Control term order on a per-post basis
- Fixing category count
- Why does WordPress combine a term with the same name in the wp_terms table?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Elegant way to add parent categories?
- Exclude Child Terms From Parent Posts
- same taxonomy for several post types: how to hide empty in a specific post type?
- How to sort terms with diacritical signs?
- get_terms(); show private posts when logged in
- Get category ID after wp_insert_term
- Send an email when custom post type category is changed
- How to order get_term_children output by alphabetic order
- get_post_terms not working as expected
- Update term count using a callback function
- wp_update_term not creating new unique slug
- Display Categories Assigned to a WooCommerce Product
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Action hooks returning old category instead of new category
- Wp set post terms not work
- Display empty taxonomy terms with get_terms()
- Get the Term List – Ordering
- Reduce / optimize calling of wp_get_object_terms() when generating permalinks
- Problems with function on function.php
- How to order and count get_terms by specific post type?
- Get those terms with a specific meta key value
- get_term_by “name” not working with & in name
- I want to loop through Woocommerce Product Catogories and show them in dropdown
- setting taxonomy term to bulk posts using ids
- display taxonomy slug from term ID
- Modify automatically generation of slug when term is created
- Custom Post Type Archive Page Filtering
- Does get_terms() use any sort of caching on its query?
- 404 on term taxonomy archive pagination only with some terms
- Clone Terms of one taxonomy to another
- Get random out from get_terms()
- Categories order with get_terms_args not working in 4.7
- Get posts from specific taxonomy term
- Getting category URL with hyphens, not spaces
- How to get a post’s associated taxonomies and terms in wp api v2
- Get all terms linked to a post and include those who not connected from get_terms and sort
- single_term_title() running before get_the_title() [closed]
- Get terms within a custom taxonomy
- How to get the $meta_type given the $object_id
- How to Link to Most Recent Custom Post of Same Term
- Parent category / child category posts
- $args for get_terms() to return ORDER BY FIELDS
- Temporarily un-associate term for an amount of time
- How to extract one field from wp_get_post_terms objects?
- Getting Category Children
- Showing HTML if Post is In Certain Taxonomy Term
- Get Custom Post Child Term
- Get fuzzy matches from get_term_by
- Taxonomy Drop Down with hierarchical view using $terms
- How to check if a term is parent to another?
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Add properties to term object
- How to show posts from category A on category B page?
- How to use category slug to echo a page’s content with the same slug
- Can we apply hide empty to get_the_terms?
- Sort categories by custom field in WordPress admin
- How to display custom taxonomy term specific post?
- Why does term get inserted twice when using dynamic slug?
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- How to use get_terms() returning only the terms that have posts with a certain custom field value
- Create category after theme setup and modify the default one
- Update term_id to new value wherever it exists, to combine the two.
- wp_set_post_terms struggle :(
- Add subcategories posts to the counts column at the admin’s categories list
- How to show only tagged CPT categories / taxonomies for a custom post type?
- Get category of a taxonomy for a queries object in a loop
- Order terms by creation date
- Unable to retrieve any child terms using get_terms
- WordPress using get_term to retreive slug not working as expected
- Get terms parent ID for conditional IF statement
- Get count for all terms inside a parent term
- Display List of Categories Within a Custom Taxonomy
- add links to list of post terms
- List Terms by category
- When I Use function wp_insert_term() function it gives me Invalid taxonomy object
- How to add a new child category via an SQL statement?
- Why is my post categories not displaying?
- Use get variable when rewritten url in wordpress
- Attempting to filter posts using get_terms
- Issue on Listing Sub Product Categories In Woocommerce
- I need to get all categories from a WP_Query
- How can I replace the values in WP_Term?