• Im looking for a really simple condition I can use along with wp_get_nav_menu_items() so that I can tell which menu item should be labeled as current.

    I tried using if( is_page($item->ID) ) but it doesn’t always highlight a menu item, sometimes there are no active menu items even though Im on the page I click through the menu.

    any help is appreciated.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    is_page() only returns true if the ID passed is for a post type Page. It does not work for your purposes for non-Page post type pages, if that makes any sense.

    There may be an easier way, but you could compare the value in the guid column of the menu object, with the domain portion stripped out, against the value in $_SERVER[‘REQUEST_URI’]. Untested idea, but I think it should work.

Viewing 1 replies (of 1 total)
  • The topic ‘Dynamic Menu Highlighting’ is closed to new replies.