[wp-trac] [WordPress Trac] #14529: wp_nav_menu() gives different results when called multiple times - reproducable
WordPress Trac
wp-trac at lists.automattic.com
Wed Aug 4 13:05:49 UTC 2010
#14529: wp_nav_menu() gives different results when called multiple times -
reproducable
--------------------------+-------------------------------------------------
Reporter: juggledad | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 3.0.1
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
If you call wp_nav_menu() with the same parameters twice, you get
different results.
To reproduce
1) use the TwentyTen theme
2) add two categories: CAT-PARENT and CAT-CHILD
3) add two pages: PAGE-PARENT and PAGE-CHILD
4) add a menu, add the two categories and two pages and adjust them so the
children are under the parents
5) edit the header.php from twentyten and after line 67 (which should be
' </div><!-- #branding -->'
add
<?php
echo '<strong>wp_nav_menu=<br></strong>';
wp_nav_menu( array( 'container_class' => 'menu-xxx', 'theme_location' =>
'primary' ) );
echo '<strong>END wp_nav_menu<br></strong>';
?>
<?php
echo '<strong>wp_nav_menu=<br></strong>';
wp_nav_menu( array( 'container_class' => 'menu-xxx', 'theme_location' =>
'primary' ) );
echo '<strong>END wp_nav_menu<br></strong>';
?>
6) view the site and the generated source
This is the output of the two calls to wp_nav_menu():
First call results
<strong>wp_nav_menu=<br></strong>
<div class="menu-xxx">
<ul id="menu-cat_test" class="menu">
<li id="menu-item-1408" class="menu-item menu-item-type-
taxonomy menu-item-1408">
<a href="http://wp301/?cat=3">CAT-PARENT</a>
<ul class="sub-menu">
<li id="menu-item-1409" class="menu-item
menu-item-type-taxonomy menu-item-1409">
<a href="http://wp301/?cat=8">CAT-
CHILD</a></li>
</ul>
</li>
<li id="menu-item-1413" class="menu-item menu-item-type-
post_type menu-item-1413">
<a href="http://wp301/?page_id=3">PAGE-PARENT</a>
<ul class="sub-menu">
<li id="menu-item-1411" class="menu-item
menu-item-type-post_type menu-item-1411">
<a href="http://wp301/?page_id=7
">PAGE-CHILD</a>
</li>
</ul>
</li>
</ul>
</div>
<strong>END wp_nav_menu=<br></strong>
second call result
<strong>wp_nav_menu=<br></strong>
<div class="menu-xxx">
<ul id="menu-cat_test-1" class="menu">
<li class="menu-item menu-item-type-taxonomy menu-
item-1408">
<a href="http://wp301/?cat=3">CAT-PARENT</a>
<ul class="sub-menu">
<li class="menu-item menu-item-type-
taxonomy menu-item-1409">
<a href="http://wp301/?cat=8">CAT-
CHILD</a></li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-
item-1413"><a href="http://wp301/?page_id=3">PAGE-PARENT</a>
<ul class="sub-menu">
<li class="menu-item menu-item-type-
post_type menu-item-1411">
<a href="http://wp301/?page_id=7
">PAGE-CHILD</a></li>
</ul>
</li>
</ul>
</div>
<strong>END wp_nav_menu=<br></strong>
notice that the <li> in the first call have an id="menu-item-nnnn" and the
second call doesn't have that. I know that an ID can only happen once in a
page, but since there is a class with the same value, it would seem that
neithor call should have an id="..." returned to be consistant.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14529>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list