Make WordPress Core

Opened 13 years ago

Last modified 5 years ago

#19264 reopened enhancement

Add get_nav_menu_item_children()

Reported by: wpsmith's profile wpsmith Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

Just as get_page_children() exists, it would be good to have get_nav_menu_item_children(). Since the object is different the code get_page_children() needs to be slightly modified.

Attachments (1)

get_nav_menu_item_children.patch (992 bytes) - added by wpsmith 13 years ago.
Patch

Download all attachments as: .zip

Change History (5)

#1 @c3mdigital
11 years ago

  • Resolution set to wontfix
  • Status changed from new to closed
  • Version set to 3.0

Closing as wont fix for now. Feel free to reopen and provide a use case and any other supporting arguments for adding this new function.

#2 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted

#3 @eclev91
9 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Use case here:

There's the main nav on a page, but outside the main nav there may be a sub nav. Perhaps the main menu is a hamburger menu in the header, then there's a hero image, and then below that is a sub nav including the current page and its navigation children (or, if you're already on a child, its siblings and parent). I can mock that up if it doesn't make sense.

wp_nav_menu() doesn't include an argument for starting with a certain item or anything, so right now you have to do wp_get_nav_menu_items(), run _wp_menu_item_classes_by_context() on that to add the current classes, use those classes to determine if you need the parent and siblings or children, fill your own array and the print those out. I can provide a code sample for this.

Maybe there's a better way of doing this, but it seems like a fair argument for this function if your nav hierarchy is different than your page hierarchy.

#4 @SergeyBiryukov
9 years ago

  • Milestone set to Awaiting Review
Note: See TracTickets for help on using tickets.