2

Using Bootstrap 3 and Navbar Walker I am able to create dynamic dropdown on the Bootstrap and WP template but I need to add .dropdown-menu-left to the .dropdown-menu class, as well.

As you can see I tried this by addig this line

'dropdown_class'    => 'dropdown-menu dropdown-menu-left',

to the original code but apparently it is not functioning correctly.

    <?php
        wp_nav_menu( array(
            'menu'              => 'desktop-main-menu',
            'theme_location'    => 'desktop-main-menu',
            'depth'             => 2,
            'container'         => 'div',
            'container_class'   => 'collapse navbar-collapse',
            'container_id'      => 'desktop-navbar-main-collapse',
            'menu_class'        => 'nav navbar-nav navbar-right',
            'dropdown_class'    => 'dropdown-menu dropdown-menu-left',
            'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
            'walker'            => new WP_Bootstrap_Navwalker())
        );
    ?>

can you please let me know how I can add the .dropdown-menu-left ul?

Behseini
  • 6,066
  • 23
  • 78
  • 125

1 Answers1

0

Just Update the wp-bootstrap-navwalker.php From

public function start_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat( "\t", $depth );
    $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu \" >\n";
}

To

public function start_lvl( &$output, $depth = 0, $args = array() ) {
    $indent = str_repeat( "\t", $depth );
    $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu dropdown-menu-left\" >\n";
    }
Suffii
  • 5,694
  • 15
  • 55
  • 92