[wp-trac] [WordPress Trac] #13793: Missing child_of parameter to wp_get_nav_menu_items

WordPress Trac wp-trac at lists.automattic.com
Fri Jun 11 23:45:46 UTC 2010


#13793: Missing child_of parameter to wp_get_nav_menu_items
-------------------------+--------------------------------------------------
 Reporter:  DreadLox     |       Owner:                
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Future Release
Component:  Menus        |     Version:  3.0           
 Severity:  normal       |    Keywords:  has-patch     
-------------------------+--------------------------------------------------

Comment(by DreadLox):

 Replying to [comment:5 filosofo]:
 > Replying to [comment:4 DreadLox]:
 > > Also what my patch provides can't be achieved using a plugin. Maybe
 you could just add an action/filter, so such a functionality could be
 implemented using a plugin.
 >
 > Actually you can, a number of ways.  I would either call
 `wp_get_nav_menu_items` directly or extend the `Walker_Nav_Menu` class.

 When using `wp_get_nav_menu_items` directly I then miss all the wordpress
 great code that generates the html menu with classes etc... Extending
 `Walker_Nav_Menu` class is rather complicated.

 > What is the use-case for this feature?

 I have some websites where the first level of the menu get displayed as
 the website "top bar" menu. When one enters one of those, a submenu of
 that level get displayed in the sidebar. (plz excuse my bad english)

 So, I first get the current page's top parent ID and then:
 if($TopParentId) wp_nav_menu( array('child_of'=>$TopParentId)  );

 Again if you really do not want such a specific feature just add a filter
 to menu_items:

 $menu_items = apply_filters( 'wp_nav_menu_items', $menu_items, $args );

 Thanks.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13793#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list