我在我的wordpress网站上使用了WP bootstrap navwalker。菜单的桌面版本正常运行,但是汉堡菜单存在一些问题。汉堡菜单正在显示,但折叠功能不起作用。 这是我的Navwalker菜单:
<nav class="navbar navbar-expand-lg navbar-light bg-color">
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span>
<i class="fas fa-bars"></i>
</span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2, // 1 = no dropdowns, 2 = with dropdowns.
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'navbar-nav mr-auto',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
?>
</ul>
</div>
</nav>
这是我排队的脚本:
//Register WP NAVWALKER
require_once('wp-bootstrap-navwalker.php');
//Theme Support
function wpb_theme_setup(){
//NAV Menus
register_nav_menus(array(
'primary' =>__('Primary Menu')
));
//CSS Files
wp_enqueue_style('font-awesome', '//use.fontawesome.com/releases/v5.5.0/css/all.css');
wp_enqueue_style('bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css');
wp_enqueue_style('owl-carasoul', '//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css');
wp_enqueue_style( 'baguette-box', '//cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css');
wp_enqueue_style('main-css', get_stylesheet_uri(), NULL, microtime(), false);
//Scripts
wp_enqueue_script('jquery', '//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js', NULL,'1.0', false);
wp_enqueue_script('owl', '//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js', NULL, '1.0', true);
wp_enqueue_script('bootstrap-js', '//stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js', NULL, '4.1.3', true);
wp_enqueue_script('baguette-js', '//cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.js', NULL, '1.10.0', false);
}
add_action('after_setup_theme', 'wpb_theme_setup');