【问题标题】:Why is my Navbar not expanding in Wordpress?为什么我的导航栏没有在 Wordpress 中扩展?
【发布时间】:2020-07-10 13:59:54
【问题描述】:

我目前正在尝试在 wordpress 中创建导航栏。

但是,当导航栏折叠并且汉堡图标仍然存在时,导航栏不会展开。

我查看了 Chrome 开发工具并尝试使用 $(),但它显​​示未定义,这让我认为 jquery 没有加载,但是我将它排在 functions.php 中

我有点困惑,不胜感激。

我的代码:

<?php 
    function enqueue_kraken_theme(){

        //style
        wp_enqueue_style( 
            "style",
            get_template_directory_uri(  ) ."/style.css",
            array()
        );

          //bootstrap css
          wp_enqueue_style( 
            "bootstrap",
            get_template_directory_uri(  ) . "/bootstrap/css/bootstrap.min.css",
            array(),
            "3.4.1",
            "all"
        );

        //Jquery 
        wp_enqueue_script( 
            "jquery",
            get_template_directory_uri(  ) . "/js/jquery-3.4.1.js",
            array("jquery"),
            "4.4.1",
            true 
        );

        //bootstrap js
        wp_enqueue_script( 
            "bootstrap",
            get_template_directory_uri(  ) . "/bootstrap/js/bootstrap.min.js",
            array(),
            "3.4.1",
            true 
        );
    }

    add_action("wp_enqueue_scripts", "enqueue_kraken_theme");

    function kraken_theme_setup(){

        add_theme_support( "menus" );

        register_nav_menu( "primary", "Primary Header Navigation" );
    }
    add_action( "after_setup_theme", "kraken_theme_setup" );

【问题讨论】:

    标签: javascript jquery wordpress twitter-bootstrap


    【解决方案1】:

    我认为 jquery 注册不正确。您应该将 jquery 替换为新版本。

    wp_register_script('jquery', get_template_directory_uri(). "/js/jquery-3.4.1.js", null, null, true); wp_enqueue_script('jquery');

    【讨论】:

    • 如果您有问题,请告诉我。我会帮你的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 2022-11-26
    • 2015-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多