Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.