WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12844 closed enhancement (fixed)

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

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

Description

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 4 years ago.

Download all attachments as: .zip

Change History (6)

tosak4 years ago

comment:1 tosak4 years ago

Patch adds menu_id argument to wp_get_nav_menu

comment:2 thee174 years ago

  • Keywords has-patch added

comment:3 nacin4 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.

comment:4 ptahdunbar4 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

comment:5 ryan4 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.