WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

share|improve this question
Return … where? Oh, and welcome to WordPress Stack Exchange! – toscho Oct 5 '12 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 '12 at 18:16

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.

share|improve this answer
Thanks @toscho. I ended up doing something a bit differently, but it still needs work. pastebin.com/TDQiQnAk – matthewell Oct 5 '12 at 21:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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