我使用的是Bootstrap+navwalker类,我的问题是单击时下拉菜单不会展开<奇怪的是,如果我更改引导程序所在的URL。js被提取到一个不正确的URL下拉列表开始工作,但是我当然得到一个警告,这个文件找不到<下面是我的代码。
密码
functions.php
<?php function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
wp_register_script( \'custom-script\', get_template_directory_uri() . \'/js/bootstrap.js\', array( \'jquery\' ) );
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( \'custom-script\' );
}
add_action( \'wp_enqueue_scripts\', \'wpbootstrap_scripts_with_jquery\' );
// Register Custom Navigation Walker
require_once(\'wp-bootstrap-navwalker.php\');
// Register Navigation Menus
register_nav_menus( array(
\'header\' => \'header\',
\'footer\' => \'footer\',
) );
?>
标题。php
<nav class="navbar navbar-inverse navbar-fixed-top" <?php echo (is_admin_bar_showing()) ? \' style="top: 32px;"\' : \'\'; ?>>
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php bloginfo(\'url\')?>"><?php bloginfo(\'name\')?></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<?php
wp_nav_menu( array(
\'menu\' => \'header\',
\'theme_location\' => \'header\',
\'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><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
感谢您的帮助!