Ok both answers are not very elegant because you have to enter the CPTs name manually. Here is a simple drop in snippet. It is pretty much copied from here so kudos to that site.
This snippet removes the current_page_parent
class of the blog menu item:
add_filter( 'nav_menu_css_class', 'theme_remove_cpt_blog_class', 10, 3 );
function theme_remove_cpt_blog_class( $classes, $item, $args ) {
if( !is_singular( 'post' ) AND !is_category() AND !is_tag() AND !is_date() ):
$blog_page_id = intval( get_option( 'page_for_posts' ) );
if( $blog_page_id != 0 AND $item->object_id == $blog_page_id )
unset( $classes[ array_search( 'current_page_parent', $classes ) ] );
endif;
return $classes;
}
Altough it wasn't asked primarily i think when removing the class from the blog menu item in most cases you want a class to highlight the CPTs archive menu item so here is a snippet for that too.
This snippet adds a current_page_parent
class on the archive menu item of a CPT:
add_action( 'nav_menu_css_class', 'theme_add_cpt_ancestor_class', 10, 3 );
function theme_add_cpt_ancestor_class( $classes, $item, $args ) {
global $post;
$current_post_type = get_post_type_object( get_post_type( $post->ID ) );
if ( $current_post_type === 'post' ) {
return $classes;
}
$current_post_type_slug = is_array( $current_post_type->rewrite ) ? $current_post_type->rewrite['slug'] : $current_post_type->name;
$menu_slug = strtolower( trim( $item->url ) );
if( strpos( $menu_slug, $current_post_type_slug ) !== false )
$classes[] = 'current_page_parent';
return $classes;
}