Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#12844 closed enhancement (fixed)

Merge wp_get_nav_menu() with wp_nav_menu() and improve arguments passed

Reported by: tosak's profile tosak Owned by: ptahdunbar's profile ptahdunbar
Milestone: 3.0 Priority: low
Severity: minor Version: 3.0
Component: Menus Keywords: wp_get_nav_menu, id has-patch
Focuses: Cc:


It's currently not possible to get an id on the ul element returned by wp_get_nav_menu (only class), if I want an id I'd have to use wp_nav_menu, but that wraps the ul in a div. This is unnecessary markup.

This can be fixed by adding an menu_id argument, just like there's an menu_class argument.

Attachments (1)

wp-menu-template.patch (1.1 KB) - added by tosak 14 years ago.

Download all attachments as: .zip

Change History (6)

#1 @tosak
14 years ago

Patch adds menu_id argument to wp_get_nav_menu

#2 @thee17
14 years ago

  • Keywords has-patch added

#3 @nacin
14 years ago

  • Milestone changed from Unassigned to 3.0

I spoke with ptahdunbar and we're going to probably combine wp_get_nav_menu() and wp_nav_menu(). The latter does allow you to omit the div, and it then passes its arguments to wp_get_nav_menu(), which then spits out the ul with classes.

I see it as working like this: optional container element (not just div, as many will want to use the new HTML5 nav element), along with an optional ID. The id is applied to the container, or if no container, then the id is applied to the ul. We'll probably need separate container and ul classes though.

We also need to make sure we're properly escaping attributes.

#4 @ptahdunbar
14 years ago

  • Owner changed from ryan to ptahdunbar
  • Status changed from new to accepted
  • Summary changed from wp_get_nav_menu UL ID to Merge wp_get_nav_menu() with wp_nav_menu() and improve arguments passed

#5 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [14031]) Nav menu fixes. Props ptahdunbar. see #12896 fixes #12844

Note: See TracTickets for help on using tickets.