This is part of code in _wp_menu_item_classes_by_context()
that handles current class for pages:
// if the menu item corresponds to the currently-queried post or taxonomy object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) )
)
) {
$classes[] = 'current-menu-item';
- IDs must match.
- It must be of
post_type
type. - Query should be for
is_singular
.
Second point can be excluded, because CSS class for item type is generated correctly. So something goes wrong either with IDs or is_singular
conditional.
Are you running any secondary loops on page? Most common reason for conditionals to break is improper use of query_posts()
.