Opened 13 years ago
Last modified 5 years ago
#19264 reopened enhancement
Add get_nav_menu_item_children()
Reported by: | 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)
Change History (5)
#1
@
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.
#3
@
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.
Patch