current-menu-item not added on page showing custom post type (rendered with archive template)

If you using wp nav menu you can use this to add the current-menu-item class put this in your theme functions.php file and remember to change “mypageslug” to your wanted current page:

function additional_active_item_classes($classes = array(), $menu_item = false){
    global $wp_query;

    if ( $menu_item->post_name == 'mypageslug' && is_page_template('archive-expertizeom.php') ) {
        $classes[] = 'current-menu-item';
    }

    return $classes;
}
add_filter( 'nav_menu_css_class', 'additional_active_item_classes', 10, 2 );

This Code adds the class “current-page-item” if you are on a page with the template archive-expertizeom.php and the menu have a post_name that matches the post_name “mypageslug ie the slug of the wanted page.