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.

Im currently printing out:

<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

Which outputs:

<div class="menu">
<ul>
<li class="current_page_item">Frontpage</li>
<li class="page_item page-item-2">etc</li>
</ul>
</div>

In my original HTML setup ive got an <span> within the <li> which looks like this:

<div id="menu">
  <ul>
    <li>
      <span>
        <a href="#">Menu1</a>
      </span>
    </li>

Any ideas on how to adjust this?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Use the arguments before and after:

wp_nav_menu(
    array(
        'theme_location' => 'primary',
        'menu_class' => 'nav-menu',
        'before' => '<span>',
        'after' => '</span>'
    )
);

To see how these arguments are used, look at the method start_el() in Walker_Nav_Menu:

    $item_output = $args->before; // 'before'
    $item_output .= '<a'. $attributes .'>';
    $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
    $item_output .= '</a>';
    $item_output .= $args->after; //'after'
share|improve this answer
    
Hi Toscho, thanks a lot for your response. I tried what you suggested, but am not seeing any <span> in the output. Would the thought be that the "before" + "after" will automatically set the <span> within the <li>? –  user1231561 May 3 '13 at 22:17
    
@user1231561 I tested it, see my update. Make sure, your have actually set a menu for that theme location. –  toscho May 3 '13 at 22:21
    
More info at codex.wordpress.org/Function_Reference/wp_nav_menu –  bungeshea_ May 3 '13 at 22:22
    
Thanks a lot guys - I got it working now! :) –  user1231561 May 3 '13 at 23:28

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.