/ Published in: PHP
Returns Wordpress categories as a hierarchical object (i.e. categories with subcategories)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function get_cat_hierchy($parent,$args){ $cats = get_categories($args); $ret = new stdClass; foreach($cats as $cat){ if($cat->parent==$parent){ $id = $cat->cat_ID; $ret->$id = $cat; $ret->$id->children = get_cat_hierchy($id,$args); } } return $ret; }
URL: http://wordpress.org/support/topic/get_categories-hierarchy-not-working