Good day. There is a withdrawal category. There are categories of the first and second level. Their names are displayed in the sidebar. Clicking on a category opens the same window (another content) with a sidebar that has second-level categories. I need that always and everywhere there were ALL categories of the first level only. I do not understand what the error in the code
<div class="b-aside-menu"> <?php foreach ($categories as $category) { ?> <?php if ($category['category_id'] == $category_id) { ?> <ul><li> <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a> </li></ul> <?php if ($category['children']) { ?> <?php foreach ($category['children'] as $child) { ?> <?php if ($child['category_id'] == $child_id) { ?> <ul><li> <a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li></ul> <?php } else { ?> <ul><li> <a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li></ul> <?php } ?> <?php } ?> <?php } ?> <?php } else { ?> <ul><li> <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li></ul> <?php } ?> <?php } ?> </div>