Modifying the behaviour of the WordPress Menu states
-
This is a long shot but I’m developing a new theme and have hit a issue which I’m wondering if it’s possible to solve.
For my navigation I’m taking advantage of the WordPress Menu feature. Everything works fine, I have a total of 6 navigation links 3 custom links 3 pages all assigned to the menu via the WordPress Menu editor, navigation code is completely dynamic and generated via wp_nav_menu. The nav links are:
Home – Link
About – Page
Contact – Page
Tutorials – Link
Articles – Link
Links – PageAll of these nav links are top level (one level)
So far everything works fine, structured correctly and displays fine, the states generated i.e. selected/active work great too and are styled slightly differently in my CSS to indicate an active page/link.
Now the problem. The two link pages Tutorials and Articles have the URL path of mydomain.com/category/tutorials and mydomain.com/category/articles which pull all posts in those categories. Problem is once a post is clicked within that category the URL changes to my permalinks settings YYYY/MM/DD and the selected/active state is then lost due to it not being a page/link in the menu.
My question is if its possible to modify the functionality of the WordPress Menu system to apply the active class generated on the tutorial or article top level link when say a post of that category is viewed? It seems a bit bespoke so I wondered if I could code up something in my functions.php to add additional behaviour to the Menu system.
Thanks in advance,
James
- The topic ‘Modifying the behaviour of the WordPress Menu states’ is closed to new replies.