2017-05-04 70 views
2

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

正如你可以看到我通过addig此行

'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-left UL?

回答

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"; 
    }