Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hey guys a nice neat way I do this is to add a filter to either “wp_page_menu” or “nav_menu_css_class” depending on if you are using old or new style menus (or both if you want to support both) like so.

    function change_page_menu_classes($menu){
    	global $post;
    	if (get_post_type($post) == 'post-type-name')
    	{
    		$menu = str_replace( 'current_page_parent', '', $menu ); // remove all current_page_parent classes
    		$menu = str_replace( 'page-item-366', 'page-item-366 current_page_parent', $menu ); // add the current_page_parent class to the page you want
    	}
    	return $menu;
    }
    add_filter( 'wp_page_menu', 'change_page_menu_classes', 0 );
Viewing 1 replies (of 1 total)