How do I add custom class to main menu. The main menu links are like Fashion, Art, Life and nodes being viewed category can be any one. I want to make the main menu item active as per node being viewed category. e.g if example.com/node/44 -> category = fashion then the Fashion in main menu should be selected. I tried MYTHEME_menu_link and MYTHEME_menu_link_alter but they did not work for me.

Thanks for your help.

1 Answer 1


I can't tell you how this works programatically, but with menu-position module you can achieve exactly what you're looking for. You'll just add a position-rule for your node-types (or taxonomy item used) to highlight a parent item accordingly.

  • Give a try to Menu attribute module. you can easily add class or id to menu items.
    – nit3ch
    Apr 8, 2013 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.