Answer the question
In order to leave comments, you need to log in
How to get to the parent category when clicking on the active subcategory?
decided!
<li<?php if ($category->term_id == $cat) { ?> class="active" <?php } ?>><a <?php if ($category->term_id == $cat) { ?> href="<?php echo get_category_link($category->parent); ?>" <?php } ?> href="<?php echo get_category_link($category->term_id); ?>" ><?php echo $category->name; ?></a></li>
Answer the question
In order to leave comments, you need to log in
Do you have this menu or what? AJAX or not?
The easiest way is to check in PHP whether this link is active and if active puts another href
The second way to do it in JS, the active item must have the class active, when clicking on the active item, the parent should be clicked through the script
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question