The below filter adds your class based on title, you could also do this by post ID if you’d like: $item->object_id == 123
function wp_nav_parent_class( $classes, $item ) {
if( is_singular('post') && $item->title == "Your Menu Item Title Here" )
array_push($classes, 'current_page_parent');
return $classes;
}
add_filter('nav_menu_css_class', 'wp_nav_parent_class', 10, 2);
If is_singular('post')
does not work try is_single()
, but it should work. Just replace the conditional string with the menu item title of your choice.