The “li class” of the parent category causes all childs links to highlight! Help
-
Hello,
I’m trying to highlight my current category in my wordpress dropdown menu.
Im using wp_list_categories, which automatically amends a list class of <li class=”current-cat”> to the top level category, when the category is selected. When a child category is selected it automatically amends the “current-cat” class to the child and “current-cat-parent” to the top level category.
This seemed great and I went ahead and added the following to my css.
ul.main li.current-cat a{background:#444;}
This works great when I am on the child category page. As the category has the background #444 in the dropdown menu.
However, there is a problem when im on the top level category. As every single child category, as well as the parent is highlighted #444.
Looking at the source code I can see why.
<li class="cat-item cat-item-1 current-cat-parent"><a href="">Parent Category</a> <ul class='children'> <li class="cat-item cat-item-4"><a href="">Child Category 1</a></li> <li class="cat-item cat-item-5 current-cat"><a href="">Child Category 2</a></li> <li class="cat-item cat-item-6"><a href="">Child Category 3</a></li> </ul> </li>
The li of the parent category is open for the entire list of child categories. So whatever css style is applied to the parent category, the same style is given to all the child categories. So when I am am on the parent category pages every single item in this category is highlighted #444.
Is there a solution so when im on the parent cat only this link is highlighted and not all the child cat links aswell?
Thanks in advance! ??
- The topic ‘The “li class” of the parent category causes all childs links to highlight! Help’ is closed to new replies.