如何使用 get_template_directory_uri() 正确实现 jQuery 菜单功能到 Wordpres


How to correctly implement jQuery menu function into Wordpress using get_template_directory_uri() for

我一直在专门使用主题构建Wordpress网站,我对巨大的臃肿主题网站感到沮丧。 我已经冒险了,并正在尝试使用Underscores框架构建我的第一个站点。

我目前在Wordpress网站中实现一些jQuery菜单滑块时遇到问题:www.AtlanticWebsites.co.uk

我想实现一些来自bigSlide的jQuery.js

http://ascott1.github.io/bigSlide.js/#how

我采取的步骤:

已将大幻灯片.js文件上传到 js.folder/目录

这包含以下所有代码:https://raw.githubusercontent.com/ascott1/bigSlide.js/master/dist/bigSlide.min.js

将以下代码插入到函数.php文件中:

function atlanticwebsites_init_js_scripts() {
wp_enqueue_script('big_Slide', get_template_directory_uri() .
'/js/bigSlide.js', array('jquery'), '1.0', true);
}
add_action('wp_enqueue_scripts', 'atlanticwebsites_init_js_scripts' );

将以下代码插入到标头.php文件中:

<a href="#menu" class="menu-link">&#9776;</a>
    <nav id="menu" class="panel" role="navigation">
        <ul>
            <li><a href="#">Web Design</a></li>
            <li><a href="#">Optimisation</a></li>
            <li><a href="#">Google Adwords</a></li>
            <li><a href="#">Responsive Design</a></li>
            <li><a href="#">Our Work</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">   
</script>
<script src="jquery.big-slide.js"></script>
<script>
    $(document).ready(function() {
    $('.menu-link').bigSlide();
    });
</script>

我已将以下代码插入到样式中.css

.panel {
    position: fixed;
    left: -15.625em; /*left or right and the width of your navigation     panel*/
    width: 15.625em; /*should match the above value*/
}
.wrap {
    position: relative;
}

菜单选项卡显示,但不起作用。有人可以检查缺少什么吗?我怀疑我错误地将代码放置在任何一个

函数.php或标头.php还是省略了代码?

另外,我是否应该删除与"导航"相关的现有代码,这些代码预填充了Underscore框架基本安装?

非常感谢

我同意瓦莱里的观点

根据您的enqueue_scripts函数,bigslide.js 驻留在 js 文件夹中,但在您的标题.php文件中,您已经包含它而没有 js 文件夹,因此您可能需要检查一下。