2

使用 Bootstrap 3 和 Navbar Walker,我可以在 Bootstrap 和 WP 模板上创建动态下拉列表,但我还需要添加.dropdown-menu-left.dropdown-menu类中。

如您所见,我通过添加此行尝试了此操作

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

到原始代码,但显然它无法正常运行。

    <?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())
        );
    ?>

你能告诉我如何添加.dropdown-menu-leftul 吗?

4

1 回答 1

0

只需更新wp-bootstrap-navwalker.php发件人

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

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";
    }
于 2017-05-04T21:59:37.683 回答