Answer the question
In order to leave comments, you need to log in
How to connect OWL Carousel to Wordpress?
Hello colleagues!
The second day I'm struggling with the OWL Carousel , namely: I can't connect it so that it works.
To be more precise, the carousel itself works. Carousel items are click-and-drag, just like in the original. The problem is navigation, which does not want to work in any way.
What I'm doing now:
1. Include jquery in functions.php
function jquery_init() {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('wp_enqueue_scripts', 'jquery_init');
function natige_scripts() {
wp_enqueue_script('history-carousel', get_template_directory_uri() . '/js/owl.carousel.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'natige_scripts', 10, 1 );
<script>
jQuery(document).ready(function($) {
var owl = $("#owl-demo");
owl.owlCarousel({
items : 4, //10 items above 1000px browser width
itemsDesktop : [1000,5], //5 items between 1000px and 901px
itemsDesktopSmall : [900,3], // betweem 900px and 601px
itemsTablet: [600,2], //2 items between 600 and 0
itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
});
// Custom Navigation Events
$(".next").click(function(){
owl.trigger('owl.next');
})
$(".prev").click(function(){
owl.trigger('owl.prev');
})
$(".play").click(function(){
owl.trigger('owl.play',1000); //owl.play event accept autoPlay speed as second parameter
})
$(".stop").click(function(){
owl.trigger('owl.stop');
})
});
</script>
Answer the question
In order to leave comments, you need to log in
It was necessary to immediately open Firebug and see the errors. It turns out that the dropdown menu script was in conflict with the carousel script.
Corrected and now it remains to achieve the desired picture.
um... I'm a little confused by your jQuery connection . Unfortunately, I'm not a programmer, but a sys. admin, but isn't it done like this:
$(document).ready(function() {
var owl = $("#owl-demo");
owl.owlCarousel({
The method you suggested connects to html, not to wordpress. Read the relevant article in the code
the only thing I can advise you is to try to replace the jQuery connection with Google's one, there it is still given gzip + caching is better
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question