Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created an menu by admin panel > Appearence > Menu. I have just one menu page in menu_lateral_1 .

Or the result is

<li id="menu-menu_lateral_1" class="menu"></li>
<li id="menu-item-212" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-212"><a href="my_website">my page</a></li>

With following code :

    $args = array(
        'menu' => 'menu_lateral_1',
        'container' => '',
        'items_wrap' => '<li id="%1$s" class="%2$s">%3$s</li>'
);
wp_nav_menu($args);

I don't understand where the first item comes ?!

share|improve this question
    
Are you sure you gave the menu the position it has on the frontend? What happens is you add a custom link to an external website? –  janw Apr 26 '12 at 8:47
add comment

1 Answer

up vote 1 down vote accepted

Take a look at the Codex documentation. The items_wrap attribute is for wrapping the list elements as a whole - not each individual menu item:

Whatever to wrap the items with an ul, and how to wrap them with

If you look at this line you'll see that it is using sprintf to replace three place-holders in the provided items_wrap. The first being an ID, the second a class, and lastly the items.

Try:

wp_nav_menu( array( 
    'menu' => 'menu_lateral_1', 
    'items_wrap' => '<ul id=\"%1$s\" class=\"%2$s\">%3$s</ul>' 
  ) ); ?>

This should give:

<ul id="menu-menu_lateral_1" class="menu">
    <li id="menu-item-212" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-212"><a href="my_website">my page</a></li>
</ul>

Note: You should use theme_location rather than menu.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.