WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_nav_menu - Add span class (5 posts)

  1. nxtstudios
    Member
    Posted 4 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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?

  3. nxtstudios
    Member
    Posted 4 years ago #

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

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  5. nxtstudios
    Member
    Posted 4 years ago #

    That did the trick.. thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags