WordPress如何在<li>和<a> inside nav menu using WP_Bootstrap_Navwalker

时间:2019-02-28 12:11:31

标签: wordpress

I am changing HTML file to wordpress theme. I have changed nav menu to wordpress menu but i couldn't add class in li and a. Like <li class="nav-item"> and <a href="#" class="nav-link">Here is my code HTML :

<nav class="navbar navbar-expand-lg navbar-light bg-light">  
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>          

        </ul>
    </div>

</nav>

Wordpress Code:

<?php
             wp_nav_menu( array(
             'menu'              => 'primary',
             'theme_location'    => 'header-menu',
             'depth'             => 2,
             'container'         => 'div',
             'container_class'   => 'collapse navbar-collapse',
             'container_id'      => 'navigation',
             'menu_class'        => 'navbar-nav ml-auto text-center',

             'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
             'walker'            => new wp_bootstrap_navwalker())
             );
        ?>

0 个答案:

没有答案