Get multidimensional array that reflects category hierarchy
So here is a function that can be used just like WordPress get_categories but returns a hierarchical array. For this there is a child_categories property added to each WP_TERM object: function get_categories_hierarchical( $args = array() ) { if( !isset( $args[ ‘parent’ ] ) ) $args[ ‘parent’ ] = 0; $categories = get_categories( $args ); foreach( … Read more