function compare_display_tree($cat, $taxonomy) { echo '<ul class="list-unstyled">'; foreach ($cat->children as $key => $child) { echo '<li> <a href="' . esc_url(add_query_arg(array($taxonomy => $child->slug), compare_get_permalink_by_tpl('page-tpl_search_page'))) . '">' . $child->name . '</a> <span class="count">' . $child->count . '</span>'; if (!empty($child->children)) { compare_display_tree($child, $taxonomy); } echo '</li>'; } echo '</ul>'; }
} ?> </h4> </div> <div id="collapse_<?php echo esc_attr($cat->slug); ?> " class="panel-collapse collapse" role="tabpanel" aria-labelledby="acc_<?php echo esc_attr($cat->slug); ?> "> <div class="panel-body"> <?php if (!empty($cat->children)) { compare_display_tree($cat, 'product-cat'); } ?> </div> </div> </div> </div> <?php } } ?> </div> </div> </div> </section> <?php