2016-06-16 49 views
1

配偶,我無法將貓頭鷹旋轉木馬集成到我的Wordpress網站中。我的頁面上沒有看到旋轉木馬。謝謝!將貓頭鷹旋轉木馬集成到WordRpess中

我的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> 

我的文件結構是:

TEMPLATENAME /資產/ CSS/

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

TEMPLATENAME /資產/ JS/

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

任何想法傢伙? – Morgari

回答

2

哪裏是你的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> 
+1

你的情況:' ' – Jamdev

+0

呵呵,非常感謝!當然,它的作品! – Morgari

相關問題