Active states (current item markup) for Mega Menu items

Hi guys,

Just adding this one here although I’ve some more details on my ‘how to’ at Active (current item) states for Mega Menu

But I can’t see any other comments/feature requests on this but believe we will need some kind of method to add active state highlighting (or at least classes in them) to the top/parent menu items in the Mega Menu, exactly as the older Nav Menu does at present, which it does excellently.

Some other detection method for the current page so that active state classes could be added to any menu item found in the Mega Menu would be a huge amount of icing on the cake.

Many thanks guys.

Q.

top dude Manc suggested some starter js for this, to get the idea across…

<script>
var current = 0;
for (var i = 0; i < document.links.length; i++) {
    if (document.links[i].href === document.URL) {
        current = i;
    }
}
document.links[current].classList.add('active');
</script>

That js is kinda quick n dirty though haha. I think at least a few issues with the active state should be solved with the latest beta since it lets you assign actual wp menus to dropdowns and mega menus.

Depending on the complexity of the mega menu we’ll end up with a bunch of menus but since they are native wp menus, active states should work. If someone already tested that, feel free to report back so we can figure out what’s still missing :slight_smile:

Excellent dude. Looking forward to testing that more too. cheers