-5
我試圖在WordPress中創建滑塊。下面是我使用的代碼:Uncaught TypeError:Object [object Object] has no method'carouFredSel'
<?php
// Enqueue Flexslider Files
function wd_slider_scripts() {
//wp_enqueue_script('jquery');
wp_enqueue_style('carouFredSel-style', get_template_directory_uri() . '/inc/client_slider/css/style.css');
wp_enqueue_script('carouFredSel-script', get_template_directory_uri() . '/inc/client_slider/js/jquery.carouFredSel-6.1.0-packed.js', array('jquery'), false, true);
wp_enqueue_script('touchSwipe-script', get_template_directory_uri() . '/inc/client_slider/js/jquery.touchwipe.1.1.1.js', array('jquery'), false, true);
}
add_action('wp_enqueue_scripts', 'wd_slider_scripts');
// Initialize Slider
function wd_slider_initialize() { ?>
<script type="text/javascript">
jQuery('#partners-slider .slider-holder2').carouFredSel({
align: 'center',
items: {
visible: "variable",
width: "variable"
},
scroll: 1,
prev: ".prev-arr",
next: ".next-arr"
});
</script>
<?php }
add_action('wp_footer', 'wd_slider_initialize');
// Create Client Slider
function wd_client_template() {
// Query Arguments
$args = array(
'post_type' => 'clients',
'posts_per_page' => 5
);
// The Query
$the_query = new WP_Query($args);
// Check if the Query returns any posts
if ($the_query->have_posts()) {
// Start the Client Slider ?>
<section></section>
<section class="partners">
<div id="partners-slider">
<div class="caroufredsel_wrapper" style="display: block; text-align: start; float: none; position: relative; top: auto; right: auto; bottom: auto; left: auto; z-index: auto; width: 100%; height: 52px; margin: 0px; overflow: hidden;">
<div class="slider-holder2" style="text-align: left; float: none; position: absolute; top: 0px; right: auto; bottom: auto; left: -188.89493620243093px; margin: 0px; width: 4105px; height: 52px; z-index: auto;">
<?php
// The Loop
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php echo the_post_thumbnail(); ?>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="slider-arr">
<a class="prev-arr arr-btn" href="#" style="display: block;"></a>
<a class="next-arr arr-btn" href="#" style="display: block;"></a>
</div>
</section>
<?php }
// Reset Post Data
wp_reset_postdata();
}
我面臨的一個錯誤:
Uncaught TypeError: Object [object Object] has no method 'carouFredSel'
您到目前爲止嘗試過了哪些?您是否縮小了代碼以查明哪個部分導致錯誤?上下文是什麼?你安裝了插件嗎? – Sam