Mark parent category menu active on single custom post view in WordPress

Muhammad Jawaid Shamshad
Ibexoft
Published in
1 min readMar 29, 2018

Recently I developed a theme for one of my client and I had to highlight the menu item of parent category in main menu when one of its associated single custom post is viewed. For that I had to add an action in my functions.php file for nav_menu_css_class. What is does is it returns the ‘active’ class which WordPress adds to the parent category menu item in the main menu. You can see the code at Gist here.

Originally published at J Talk’s

--

--

Muhammad Jawaid Shamshad
Ibexoft

I'm a passionate software developer with a love for web technologies. Join me on this journey as we explore the fascinating world of software development.