Get all IDs of subcategories
-
Hi!
I want to get all subcategories of parent category
How i think to do it:
1. Get ParentID with no metter if I am in Sub or Parent cat:$category = get_the_category(); $hierarchy = array_reverse( get_ancestors( $category[0]->term_id, 'category' ) ); $hierarchy[] = $category[0]->term_id; $parent_id=$hierarchy[0];
2. Now when i have parent id, i can get arrays with subcat
$all_cats[]=( get_terms(array('category'),array('child_of' => $categories)));
3. How to extrac only IDs of subcategories [‘term_id’] + parent ID?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get all IDs of subcategories’ is closed to new replies.