i’ve problem with owl carousel in wordpress theme.
owl carousel works correctly in static page. but when i turn my page to wordpress theme , the images(carousel) have disappear.
here are my try in static mode (owl carousel works fine):
added libraries:
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-rtl.min.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome-animation.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="css/owl.carousel.css">
<link rel="stylesheet" href="css/owl.theme.css">
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/countUp.min.js"></script>
<script src="js/flowtype.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/mk_theme.js"></script>
Html:
<!-- Links -->
<div class="links">
<div class="container">
<div id="links-carousel" class="owl-carousel owl-theme">
<div class="">
<a href="#"><img alt="links" src="img/links/01.png"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="img/links/02.png"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="img/links/03.png"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="img/links/04.png"></a>
</div>
</div>
</div>
</div>
<!-- End Links -->
js(mk_theme.js):
var owl = $("#links-carousel");
owl.owlCarousel({
itemsCustom : [
[450, 2],
[700, 3],
[1600, 4]
],
navigation : false
});
I turned my static page to wordpress theme:
added libraries in function.php
function mes_scripts() {
wp_enqueue_style( 'owl-carousel', get_template_directory_uri() . '/css/owl.carousel.css', array(), '1.3.3' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.3.0' );
wp_enqueue_style( 'bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.4' );
wp_enqueue_style( 'bootstrap-rtl', get_template_directory_uri() . '/css/bootstrap-rtl.min.css', array(), '3.3.2' );
wp_enqueue_style( 'font-awesome-animation', get_template_directory_uri() . '/css/font-awesome-animation.css', array(), '0.0.7' );
wp_enqueue_script( 'jquery-1.11.2.min', get_template_directory_uri() . '/js/jquery-1.11.2.min.js', array(), '1.11.2' , true );
wp_enqueue_script( 'owl-carousel-min', get_template_directory_uri() . '/js/owl.carousel.min.js', array(), false , true );
wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/js/jquery.easing.min.js', array(), '1.3', true );
wp_enqueue_script( 'bootstrap-script', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.3.4' , true );
wp_enqueue_script( 'countUp', get_template_directory_uri() . '/js/countUp.min.js', array() , false , true );
wp_enqueue_script( 'flowtype', get_template_directory_uri() . '/js/flowtype.js', array(), '1.1' , true );
wp_enqueue_script( 'mk-theme', get_template_directory_uri() . '/js/mk_theme.js', array() , false , true );
}
add_action( 'wp_enqueue_scripts', 'mes_scripts' );
index.php:
<!-- Links -->
<div class="links">
<div class="container">
<div id="links-carousel" class="owl-carousel owl-theme">
<div class="">
<a href="#"><img alt="links" src="<?php echo get_template_directory_uri() . '/img/links/01.png' ?>"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="<?php echo get_template_directory_uri() . '/img/links/02.png' ?>"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="<?php echo get_template_directory_uri() . '/img/links/03.png' ?>"></a>
</div>
<div class="">
<a href="#"><img alt="links" src="<?php echo get_template_directory_uri() . '/img/links/04.png' ?>"></a>
</div>
</div>
</div>
</div>
<!-- End Links -->
and i didn’t change js codes in wordpress theme(mk_theme.js)
check out your codes for any errors(in google chrome use Ctrl + Shift + I).
also in some cases it will be work on change “owl-carousel” to another version.