WP grandchild categories in nested ul li

You can’t do it using simple for/foreach loops. This is an excellent example where a recursion can help: function get_categories_list( $parent, $use_toggle = true ) { $result = “”; $categories = get_categories( array ( ‘parent’ => $parent ) ); if ($categories) { foreach ($categories as $category) { $name = $category->name; // HERE THE RECURSION IS … Read more