Opened 15 years ago
Last modified 7 years ago
#19264 reopened enhancement
Add get_nav_menu_item_children()
| Reported by: | wpsmith | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Menus | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
13 years ago
- Resolution → wontfix
- Status new → closed
- Version → 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
@
11 years ago
- Resolution wontfix
- Status closed → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch