响应式汉堡包/下拉菜单在Wordpress网站上不起作用

时间:2019-07-18 21:44:49

标签: php wordpress dropdown

我在Wordpress网站上的下拉菜单有问题。 基本上,我已经将菜单与一些php代码集成在一起,以便可以利用wordpress的菜单功能。但是,该菜单在桌面版本中可见,在减小屏幕宽度时会“折叠”自身,但不会执行下拉动画并​​保持静态。

请帮助我,非常感谢。

我尝试过按每个顺序移动引导cdns,首先使用jquery cdn,然后是最后一个,并将它们放在页眉中,然后放在页脚中,但是它们都得出相同的结果。 这是在本地主机环境上。

<!DOCTYPE html>
<html <?php language_attributes();?> >
<head>
  <title>
  <?php bloginfo('name');?> |
  <?php is_front_page() ? bloginfo('description') :  wp_title(); ?>
  </title>
  <meta charset="<?php bloginfo('charset')?>">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

 <link href="<?php bloginfo('stylesheet_url');?>" rel="stylesheet">
  <?php wp_head(); ?>
</head>


<body>

    <nav class="navbar navbar-expand-md navbar-light bg-light" 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="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <a class="navbar-brand" href="#">Navbar</a>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <?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 
        // Register Nav Walker class_alias  
        require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';

        // Theme Support
        if ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
        // file does not exist... return an error.
        return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
        } else {
            // file exists... require it.
            require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
        }


        register_nav_menus( array(
        'primary' => __( 'Primary Menu', 'BachusBistroChic' ),
    ) );


    ?>

此外,它在控制台中显示错误,提示它缺少popper.js文件,但是该文件已经通过引导CDN链接了。

0 个答案:

没有答案