24 | | $chain = ''; |
25 | | /** TODO: consult hierarchy */ |
26 | | $cat_ids = get_all_category_ids(); |
27 | | foreach ( (array) $cat_ids as $cat_id ) { |
28 | | if ( $cat_id == $id ) |
29 | | continue; |
30 | | |
31 | | $category = get_category( $cat_id ); |
32 | | if ( is_wp_error( $category ) ) |
33 | | return $category; |
34 | | if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
35 | | $visited[] = $category->term_id; |
36 | | $chain .= $before.$category->term_id.$after; |
37 | | $chain .= get_category_children( $category->term_id, $before, $after ); |
38 | | } |
39 | | } |
40 | | return $chain; |
| 24 | $children = get_term_children( $id, 'category' ); |
| 25 | |
| 26 | if ( !is_wp_error( $children ) && !empty( $children ) ) |
| 27 | $chain = $before . join( $before . $after, $children ) . $after; |
| 28 | else |
| 29 | $chain = ''; |
| 30 | |
| 31 | return $chain; |