有人能识别出我的NavWalker代码中有什么不起作用吗?
我不能让它掉下来。
否则效果很好。
谢谢你的帮助。
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<?php
wp_nav_menu( array(
\'theme_location\' => \'main_navigation\',
\'depth\' => 2,
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'navbarNav\',
\'menu_class\' => \'navbar-nav mr-auto\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker())
);
?>
</nav>
最合适的回答,由SO网友:Max Yudin 整理而成
错误的container_id
和menu_class
. 看见WP Bootstrap NavWalker 用法部分。
<?php
wp_nav_menu( array(
\'theme_location\' => \'primary\',
\'depth\' => 2,
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'bs-example-navbar-collapse-1\',
\'menu_class\' => \'nav navbar-nav\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker(),
) );