Is it possible to return the Page ID of menu items?

I specifically looking to get the IDs that appear in a rollover submenu.

  • Return … where? Oh, and welcome to WordPress Stack Exchange!
    – fuxia
    Oct 5, 2012 at 17:57
  • Thanks @toscho! (I know ur not real...) Let me be more descriptive... I'm looking to get the IDs from submenu items to use in the Order & Orderby Parameters of a WP_Query. The reasoning is a bit complex but was wonderding if it is possible
    – matthewell
    Oct 5, 2012 at 18:16

1 Answer 1


Hook int 'wp_nav_menu_objects'. You get a list (an array) of all found menu items as an array. Each item is an object, and each one has a property named ID. That's the ID of the original object if it was a post object.

In your filter callback just iterate over these items, collect the IDs and use them later in your custom query.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.