Assign "current" class to current submenu
-
Hi there, at first glance my questions seems to be a common and often asked one, but acutally I couldn’t find the answer yet.
So what I want is the (usual) following:
nav1
nav2
nav3
subnav1
subnav2
subnav3
nav4When I’m somewhere first level, the submenu may not show up.
When I’m navigating to nav3 it shows up (and stays).
When I’m at subnav 1 it stays.So here’s the problem. I’m using a custom menu in a sidebar widget. So I’m not working with wp_list_pages, nor with wp_nav. I only found solutions for those so far…
nav3 is my “blogsite”. The subnavs are categories. As long as I’m in the categories, everything is alight and displays the right way. I’m using the multiple “current-…” selectors WP puts in the li’s.
However, when I’m in a Blogentry (so to say switched from the category template to the single template), there are selectors missing to display the the other subnavs. The current-… Selector is only added to the current category, so what I get is:
nav1
nav2
nav3
subnav1
nav4So I basicly need all other subnavs (li’s) to get a current status, or the ul with the class “sub-nav” (automaticly assigned by wp).
The funny thing is – nav3 also has a “current” class, which would solve my problem, if it didn’t have that stupid class from the start, even when I totally didn’t click anything yet. It already has it when I’m loading the root page…
So another solution would be to strip that class as long as it’s not the actually current menu parent.
- The topic ‘Assign "current" class to current submenu’ is closed to new replies.