用于在 WordPress 中使用 Owl Carousel。首先,您需要将脚本排入队列
以及文件名functions.php中猫头鹰轮播和查询的样式。
查看更多信息:https://owlcarousel2.github.io/OwlCarousel2/docs/started-installation.html
wp_enqueue_style 参考:https://developer.wordpress.org/reference/functions/wp_enqueue_style/
和 wp_enqueue_script:https://developer.wordpress.org/reference/functions/wp_enqueue_script/
function loadup_scripts()
{
wp_enqueue_style('owl-carousel-css','https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css', array('jquery'),'2.3.4','all');
wp_enqueue_style('owl-theme-default-css','https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css', array('jquery'),'2.3.4', 'all');
wp_enqueue_script('owl-carousel-js','https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js',array('jquery','2.3.4',true);
}
add_action( 'wp_enqueue_scripts', 'loadup_scripts' );
#使用footer中的Wp_footer action调用插件
function livewellnutritionuk_action() { ?>
<script>
jQuery(document).ready(function(){
jQuery('.slider').slick({
infinite: false,
speed: 100,
slidesToShow: 4,
slidesToScroll: 4,
autoplay: true,
prevArrow: '<span class="priv_arrow"><</span>',
nextArrow: '<span class="priv_arrow">></span>',
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
</script>
<?php
}
add_action('wp_footer', 'livewellnutritionuk_action');