NavWalker引导错误(不会下拉)

时间:2018-01-17 作者:Henry

有人能识别出我的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>

1 个回复
最合适的回答,由SO网友:Max Yudin 整理而成

错误的container_idmenu_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(),
) );

结束

相关推荐

如何创建4列和2列Twitter-Bootstrap相结合的WordPress循环?

我想根据4列(桌面视图)、2列(mobile view 768px)和1列(mobile view 425px)的组合显示帖子。我在下面找到了很棒的代码:<?php $paged = ( get_query_var(\'paged\') ) ? get_query_var(\'paged\') : 1; $args=array( \'post_type\' => \'post\',