wp_nav_menu, one page design anchors and highlight problem
-
Hi there,
I have a one page design template theme which works fine, except for one problem I can’t overcome.
The template uses a custom menu manager, but the limitations in this menu made me decide to replace it with wordpress own menu (using wp_nav_menu). This works great, but because the website is a one page design it uses the anchors tag (the #) to go from page to page. The problem here is, is that I can not use the current-menu-item an current_page_item classes to highlight the active menu item. This is because wordpress adds these classes to all menu items (because of the one page design).
The solution would be to automatically add a custom class to the active menu item. But the problem is is that I am not that prog-shaffy to come up with a code for this.
Last couple of days I have been searching for a solution, and came across a few which worked partly. But most solutions that worked added the custom class to all menu items because they only do page checks. What I need is some sort of anchor check.
Here is the html output of the menu:
<div class="menu-hoofdmenu-container"> <ul id="menu-hoofdmenu" class="menu"> <li id="menu-item-621" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-621"><a href="https://www.3dinyourhands.com/wp_new/#home">Home</a></li> <li id="menu-item-592" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-592"><a href="https://www.3dinyourhands.com/wp_new/#portfolio">Portfolio</a></li> <li id="menu-item-594" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-594"><a href="https://www.3dinyourhands.com/wp_new/#contact">Contact</a></li> </ul> </div>
Thanks in advance.
- The topic ‘wp_nav_menu, one page design anchors and highlight problem’ is closed to new replies.