我正在为最新的WordPress开发一个bootstrap 5主题。我在这里使用Navwalker:https://github.com/wp-bootstrap/wp-bootstrap-navwalker. 我的引导导航栏不会在较小的屏幕上下拉。
因为我使用的是Bootstrap 5而不是Bootstrap 4,所以它不起作用吗?
这是我标题中的代码。php文件:
<nav class="navbar navbar-expand-md navbar-dark bg-dark" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="<?php esc_attr_e( \'Toggle navigation\', \'your-theme-slug\' ); ?>">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<?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(),
) );
?>
</div>
</nav>
这是我的函数代码。php文件:
function register_navwalker(){
require_once get_template_directory() . \'/class-wp-bootstrap-navwalker.php\';
}
add_action( \'after_setup_theme\', \'register_navwalker\' );
/*Navigation Menus*/
register_nav_menus( array(
\'primary\' => __( \'Primary Menu\', \'bootstrap\' ),
\'secondary\' => __( \'Secondary Menu\', \'bootstrap\' )
) );
这是我的错误:
警告:call\\u user\\u func\\u array()要求参数1为有效回调,在C:\\Users\\apiro\\Local Sites\\wordpressbootstraptheme\\app\\public\\wp includes\\class wp hook中找不到函数“register\\u navwalker”,或函数名无效。php在线292
调用堆栈
Time Memory Function Location
1 0.0003 413560{main}()。。。\\索引。php:0
2 0.0006 413832要求(\'C:\\Users\\apiro\\Local Sites\\wordpressbootstraptheme\\app\\public\\wp blog header.php\')。。。\\索引。菲律宾比索:17
3 0.0006 414376 require\\u once(\'C:\\Users\\apiro\\Local Sites\\wordpressbootstraptheme\\app\\public\\wp load.php\')。。。\\wp博客标题。菲律宾比索:13
4 0.0007 414816 require\\u once(\'C:\\Users\\apiro\\Local Sites\\wordpressbootstraptheme\\app\\public\\wp config.php\')。。。\\wp负载。菲律宾比索:37
5 0.0007 419496 require\\u once(\'C:\\Users\\apiro\\Local Sites\\wordpressbootstraptheme\\app\\public\\wp settings.php\')。。。\\wp配置。菲律宾比索:79
6 0.0325 2624792 do\\u action()。。。\\wp设置。菲律宾比索:538
7 0.0325 2625168 WP\\U挂钩->;do\\u操作()。。。\\插件。菲律宾比索:484
8 0.0325 2625168 WP\\U挂钩->;应用\\u筛选器()。。。\\wp级挂钩。菲律宾比索:316