Edit
Two things:
wp_nav_menu()also outputs.current_page_item, as backward compatibility withwp_page_menu().- Among the list item CSS classes added by
wp_nav_menu(), for a custom post type, list items will have a CSS class.list-type-object-{slug}, where{slug}is the CPT slug. So, you could target:.list-type-object-{slug}.current-list-item
Original Answer
The key is in the class name: .current_page_item. That class is added by wp_page_menu(), whereas wp_nav_menu() adds .current-list-item.
What that means is that wp_nav_menu() is outputting its fallback menu, and not a user-created custom nav menu.
Ensure:
- Custom nav menu Theme Location is registered via
register_nav_menu()orregister_nav_menus() - Call to
wp_nav_menu()includes thetheme_locationparameter *and not themenuparameter, and that thetheme_locationpassed towp_nav_menu()matches the one defined inregister_nav_menu()/register_nav_menus()` - At least one custom nav menu is defined via
Appearance -> Menus - A defined custom nav menu is assigned to the Theme Location that corresponds to
theme_locationpassed towp_nav_menu().
For example:
-
Register
function wpse117502_theme_setup() { register_nav_menus( array( 'primary' => 'Primary' ) ); } add_action( 'after_setup_theme', 'wpse117502_theme_setup' ); -
Call
wp_nav_menu( array( 'theme_location' => 'primary' ) ); -
Define
User creates a menu, e.g. “Main Menu”
-
Assign
User assigns “Main Menu” to “Primary” Theme Location