Add active class on menu
-
hello,
is there any way to give active class on the menu if we are in the custom post type single page? default WordPress menu has that option by adding hook. but that hook is not working with this plugin. is there any other hooks has to work with this plugin.here is the working code for WordPress default menu.
function change_page_menu_classes($menu) { global $post; if (get_post_type($post) == 'projects') { $menu = str_replace( 'current-menu-item', '', $menu ); // remove all current_page_parent classes $menu = str_replace( 'menu-item-299', 'current-menu-item', $menu ); // add the current_page_parent class to the page you want } return $menu; } add_filter( 'nav_menu_css_class', 'change_page_menu_classes', 10,2 );
Kindly please check this and let us know how we can solve this
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Add active class on menu’ is closed to new replies.