gpt4 book ai didi

javascript - 将 Owl Carousel 集成到 Wordpress 中

转载 作者:行者123 更新时间:2023-11-30 16:00:25 24 4
gpt4 key购买 nike

伙计们,我无法将 Owl Carousel 集成到我的 Wordpress 网站中。我的页面上没有看到轮播。谢谢!

我的 functions.php 代码:

function templatename_add_owlcarousel() {
wp_enqueue_script ( 'jquery' );

wp_enqueue_script( 'owlcarousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel-init.js', array( 'jquery' ), false, true );
wp_enqueue_style( 'owlcarousel-style', get_template_directory_uri() . '/assets/css/owl.carousel.css' );
wp_enqueue_style( 'owlcarousel-style', get_template_directory_uri() . '/assets/css/owl.theme.default.min.css' );
}
add_action( 'wp_enqueue_scripts', 'templatename_add_owlcarousel' );

owl.carousel.init.js 代码:

$(document).ready(function() {

$("#owl-demo").owlCarousel({

autoPlay: 3000, //Set AutoPlay to 3 seconds

items : 4,
itemsDesktop : [1199,3],
itemsDesktopSmall : [979,3]

});

});

index.php 部分代码:

<div id="owl-demo" class="owl-carousel owl-theme">
<div class="item"><h1>1</h1></div>
<div class="item"><h1>2</h1></div>
<div class="item"><h1>3</h1></div>
<div class="item"><h1>4</h1></div>
<div class="item"><h1>5</h1></div>
<div class="item"><h1>6</h1></div>
<div class="item"><h1>7</h1></div>
<div class="item"><h1>8</h1></div>
<div class="item"><h1>9</h1></div>
<div class="item"><h1>10</h1></div>
<div class="item"><h1>11</h1></div>
<div class="item"><h1>12</h1></div>
<div class="item"><h1>13</h1></div>
<div class="item"><h1>14</h1></div>
<div class="item"><h1>15</h1></div>
<div class="item"><h1>16</h1></div>
</div>

<div class="customNavigation">
<a class="btn prev">Previous</a>
<a class="btn next">Next</a>
<a class="btn play">Autoplay</a>
<a class="btn stop">Stop</a>
</div>

我的文件结构是:

模板名称/assets/css/

  • owl.carousel.css
  • owl.carousel.min.css
  • owl.theme.default.min.css

模板名称/assets/js/

  • owl.carousel.min.js
  • owl.carousel.js
  • owl.carousel-init.js

最佳答案

您的 footer.php 代码在哪里?是不是忘记将初始代码放入 footer.php 文件?

<script src="<?php bloginfo('template_directory'); ?>/js/owl.carousel-init.js"></script>

<script src="<?php bloginfo('template_directory');>/js/owl.carousel.min.js"></script>

关于javascript - 将 Owl Carousel 集成到 Wordpress 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37862116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com