When i want to add the classes current-menu-item and current-page-ancestor i always use the wp_nav_menu without any custom walker. I only build my own walker if i want to change lets say the classes to something like “sel” instead.
So i add the menu like this:
<?php
wp_nav_menu(
array(
'theme_location' => 'company-menu',
'container' => false,
'menu_class' => '',
'echo' => true,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'depth' => 2,
'items_wrap' => '<ul id="company-right-menu">' . "\n" . '%3$s</ul>' . "\n"
)
);
?>
And then i add this action to my functions.php file:
function additional_active_item_classes($classes = array(), $menu_item = false){
global $wp_query;
if( in_array('current-menu-item', $menu_item->classes) ){
$classes[] = 'current-menu-item';
}
// add class current-menu-item to archive
if ( $menu_item->post_name == 'my_custom_post' && is_post_type_archive('my_custom_post') ) {
$classes[] = 'current-menu-item';
}
// add class current-menu-item to single
if ( $menu_item->post_name == 'my_custom_post' && is_singular('my_custom_post') ) {
$classes[] = 'current-menu-item';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'additional_active_item_classes', 10, 2 );
If this is in the right direction i can help you more if you want.