I have a wordpress theme using wp_nav_menu() to build the menu. I have a custom menu item in this menu that goes to a non-standard wordpress page. Is there a way I can conditionally set this nav item to current based on a match in the url string?
Thanks
You can use the nav_menu_css_class in WordPress to achieve the result you’re after. Using this hook you can alter an array of CSS classes that can be applied to the menu.
This method will ignore 404 pages or the root of the site, but will add the class to the menu item if the current URL matches the menu item URL.
Full credit for this code: http://www.rarescosma.com/2010/11/add-a-class-to-wp_nav_menu-items-with-urls-included-in-the-current-url/