[wp-trac] [WordPress Trac] #29927: wp_nav_menu shows wrong menu when menu_id is set

WordPress Trac noreply at wordpress.org
Sat Oct 11 14:38:15 UTC 2014


#29927: wp_nav_menu shows wrong menu when menu_id is set
--------------------------+-----------------------------
 Reporter:  larsemil      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I have a site that is/was running 3.5.1.

 It had the following code:

 {{{

     <?php wp_nav_menu(
     array(
         'menu' => 'Medical Category Menu',
         'menu_class' => 'row-fluid Product main_s_cat',
         'items_wrap'  => '<ul id="%1$s" class="row-fluid Product
 main_s_cat">%3$s</ul>',
         'menu_id' => 'main_cat_menu',
         )); ?>


 }}}

 After upgrading to 4.0 the wrong menu was shown.
 Removing the line with menu_id shows the correct menu.

 Steps to reproduce(sorry for formating. i did not get it right. [Correct
 here]


 {{{
 // how to replicate:
 // 1. Create at least two menus
 // 2. Add code below to functions.php or use wp_nav_menu in theme file.

 add_action('loop_end', function(){
  wp_nav_menu(array(
   'menu' => 46, // make sure its an menu id that exist
   'menu_class' => 'row-fluid Product main_s_cat',
   'items_wrap'  => '<ul id="%1$s" class="row-fluid Product
 main_s_cat">%3$s</ul>',
   'menu_id' => 'main_cat_menu', //with this line in place, correct menu is
 NOT shown. Remove it, and correct menu is shown...
  ));
 });
 }}}


 I included the add_action as an easy way to test if not editing theme
 files... its the same if added directly into theme.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29927>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list