Support » Fixing WordPress » wp_nav_menu – Add span class

  • Resolved nxtstudios

    (@nxtstudios)


    I am trying to add a span class the first level of navigation, but can’t seem to get it to work.

    <li class="about"><a href="#"><span>About</span></a>
    <ul>
    <li><a href="#">sub1</a></li>
    <li><a href="#">sub1</a></li>
    <li><a href="#">sub1</a></li>
    </ul>

    I can add the before and after code and but <span> there, but its reflected on the second level as well.

    Here’s what i currently have

    <?php wp_nav_menu(
    array('theme_location' => 'main-menu',
    'container_id' => 'smoothmenu1',
    'container_class' => 'ddsmoothmenu',
    'link_before' => '<span>',
    'link_after' => '</span>'
    ));
    ?>

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    Forum Moderator

    I am trying to add a span class the first level of navigation

    Why – when you can apply CSS to the link text and then remove that styling via the ul ul or .submenu rules?

    I have an image for the menu on the first layer and text on the second layer.

    esmi

    (@esmi)

    Forum Moderator

    If you’re trying to apply unique images to each top level menu item, check out the individual menu-item (or page-item) ids that are generated by wp_nav_menu (or by it’s default callback, wp_page_menu) in your source markup.

    That did the trick.. thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_nav_menu – Add span class’ is closed to new replies.