How do you get the current-menu-item ID?

A little late perhaps, but there is one more way of doing it:

$menu = wp_get_nav_menu_items($menu_id,array(
   'posts_per_page' => -1,
   'meta_key' => '_menu_item_object_id',
   'meta_value' => $post->ID // the currently displayed post
));

var_dump($menu[0]->ID);

Since menu items are post-types you are able to use all the WP-Query params, even a meta query. The code above selects all menu_items which are connected to the current post, from the menu you specify via $menu_id.

Leave a Comment