Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#13597 closed defect (bug) (fixed)

Using the same menu in multiple theme_location resulting in duplicate ids

Reported by: sushicodeur's profile sushicodeur Owned by: filosofo's profile filosofo
Milestone: 3.0 Priority: normal
Severity: minor Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

I've a site using multiple menus. The menu are registered this way

if ( function_exists('register_nav_menus') ) {
  register_nav_menus(
    array(
      'social-top' => 'Top social menu',
      'social-bottom' => 'Bottom social menu',
    )
  );
}

I wish to use the same menu (named social) for the two theme locations. I call the menu with these args :

<?php
  $menu_args = array(
    'container'       => '',
    'theme_location'  => 'social-top', // and social-bottom the next time
  );
  wp_nav_menu($menu_args); 
?>

Resulting in the same opening tag for the two menus (since the id is constructed using the menu slug), which is not W3C valid :

<ul id="menu-social"><!-- found twice in the same page -->

The "container_id" option described here http://codex.wordpress.org/Function_Reference/wp_nav_menu seems to have no effect.

Attachments (1)

unique-menu-container-ids.13597.diff (2.4 KB) - added by filosofo 15 years ago.

Download all attachments as: .zip

Change History (5)

#1 @filosofo
15 years ago

  • Owner set to filosofo
  • Status changed from new to accepted

#2 @filosofo
15 years ago

  • Keywords has-patch added

#3 @eveevans
15 years ago

  • Severity changed from normal to minor

I think you can use wp_get_nav_menu_items() and wp_get_nav_menus() for have more control in the custom menus

#4 @ryan
15 years ago

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

(In [15034]) Unique menu container ids. Props filosofo. fixes #13597

Note: See TracTickets for help on using tickets.