0

In my template I have a custom menu. Below is the HTML code for it. Inside the menu there is one dropdown menu and a link tag.

<ul class="nav navbar-nav">
    <li class="active"><a href="index.html">Home</a></li>
    <li><a href="category.html">Category Page</a></li>
    <li><a href="article.html">Article Page</a></li>
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Category Type A <span class="caret"></span></a>
        <ul class="dropdown-menu forAnimate" role="menu">
            <li><a href="#">Category One</a></li>
            <li><a href="#">Category Two</a></li>
            <li><a href="#">Category Three</a></li>
        </ul>
    </li>
</ul>
1

Use wp_nav_menu() with proper parameters to add the dropdown-menu forAnimate class, to remove the wrapper and to add the role attribute:

<ul class="nav navbar-nav">
    <li class="active"><a href="index.html">Home</a></li>
    <li><a href="category.html">Category Page</a></li>
    <li><a href="article.html">Article Page</a></li>
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Category Type A <span class="caret"></span></a>
        <?php wp_nav_menu(array(
            'menu'       => 'my_menu_name', // specify the menu name
            'menu_class' => 'dropdown-menu forAnimate', // add classes for the dropdown
            'container'  => '', // don't wrap the menu in <div>
            'items_wrap' => '<ul id="%1$s" class="%2$s" role="menu" >%3$s</ul>',
        ));?>
    </li>
</ul>

'<ul id="%1$s" class="%2$s" role="menu" >%3$s</ul>' part is intended to keep id and class as is and to add the role attribute.

Not tested, though.

See wp_nav_menu() for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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