wpseek.com
A WordPress-centric search engine for devs and theme authors
get_category_children is deprecated since version 2.8.0!
Alternative: get_term_children()
Alternative: get_term_children()
get_category_children › WordPress Function
Since1.2.0
Deprecated2.8.0
› get_category_children ( $id, $before = '/', $after = '', $visited = array() )
| Parameters: (4) |
|
| See: | |
| Returns: |
|
| Defined at: |
|
| Codex: |
Retrieve category children list separated before and after the term IDs.
Related Functions: get_term_children, _get_term_children, get_page_children, get_category_link, get_category_parents
Source
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
_deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' );
if ( 0 == $id )
return '';
$chain = '';
/** TODO: Consult hierarchy */
$cat_ids = get_all_category_ids();
foreach ( (array) $cat_ids as $cat_id ) {
if ( $cat_id == $id )
continue;
$category = get_category( $cat_id );
if ( is_wp_error( $category ) )
return $category;
if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
$visited[] = $category->term_id;
$chain .= $before.$category->term_id.$after;
$chain .= get_category_children( $category->term_id, $before, $after );
}
}
return $chain;
}