Make sure cache is primed before use in get_category_children().
git-svn-id: https://develop.svn.wordpress.org/trunk@2608 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
23be7d16b7
commit
7a561d0d00
|
@ -123,16 +123,20 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename =
|
|||
}
|
||||
|
||||
function get_category_children($id, $before = '/', $after = '') {
|
||||
global $cache_categories;
|
||||
$c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
|
||||
$chain = '';
|
||||
foreach ($c_cache as $category){
|
||||
if ($category->category_parent == $id){
|
||||
$chain .= $before.$category->cat_ID.$after;
|
||||
$chain .= get_category_children($category->cat_ID, $before, $after);
|
||||
}
|
||||
}
|
||||
return $chain;
|
||||
global $cache_categories;
|
||||
|
||||
if ( ! isset($cache_categories))
|
||||
update_category_cache();
|
||||
|
||||
$c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
|
||||
$chain = '';
|
||||
foreach ($c_cache as $category){
|
||||
if ($category->category_parent == $id){
|
||||
$chain .= $before.$category->cat_ID.$after;
|
||||
$chain .= get_category_children($category->cat_ID, $before, $after);
|
||||
}
|
||||
}
|
||||
return $chain;
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
|
|
Loading…
Reference in New Issue