• 5 Subscribers

I'm trying to use wp-bootstrap-navwalker to customize my navigation.

here is the example of my current static code

<div class="collapse navbar-collapse">
  <ul class="navbar-nav nav navbar-right">
    <li><a class="menu" href="index-2.html">home</a></li>
    <li><a class="menu" href="#">travel</a></li>
    <li><a class="menu" href="#">lifestyle</a></li>
    <li><a class="menu" href="about.html">about me</a></li>
    <li><a class="last-menu" href="contact.html">contact</a></li>

I'm using this wp-bootstrap-navwalker to make it dynamic

 wp_nav_menu( array(
    'menu'              => 'primary',
    'theme_location'    => 'primary',
    'depth'             =>  2,
    'container'         => 'div',
    'container_class'   => 'collapse navbar-collapse',
    'menu_class'        => 'nav navbar-nav navbar-right',
    'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
    'walker'            => new wp_bootstrap_navwalker())

Which is working perfectly fine. Now i have a problem, That i have menu class inside my <a class="menu">home</a>. How can i put menu class inside my anchor tag if that data is coming dynamically. Is there any way that we can customize this wp_nav_menu(array( )); ?

1 answers in total

Ruhul Amin Posted at 2017-01-11 22:51:12Z

The wordpress way would be to add 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', to wp_nav_menu(array( )) then you will have special class for custom nav items and normal links items. Then you can target them from CSS. Usefull link: wp_nav_items css

Otherwise you need to change: wp_bootstrap_navwalker

Answer this questsion