B
B
Boris Belov2015-10-15 21:55:47
JavaScript
Boris Belov, 2015-10-15 21:55:47

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

1 answer(s)
S
Sergey, 2015-10-15
@gangstarcj

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 question

Ask a Question

731 491 924 answers to any question