你好我试图禁止这个幻灯片自动移动。你可以帮忙吗? 我几乎尝试了所有我能做但我无法做到的事情。这是functions.php文件的一部分,其中包含脚本,因为我希望我放置正确的代码
<div id="banner" class="blog-carousel-v2">
<script>
jQuery(document).ready(
function() {
jQuery(".blog-carousel-v2 .sliderpagination").niceScroll({
cursorwidth : 10,
cursorcolor :"#616161",
autohidemode:false,
cursorborder : '2px solid #131313',
railoffset:true,
cursorborderradius : 0,
background: "#161616"
});
});
</script>
<?php
$slider_pagination = array();
echo '<div class="cycle-slideshow"
data-cycle-fx=fade
data-cycle-timeout=0
data-cycle-auto-height=container
data-cycle-slides="article"
data-cycle-random=false
data-cycle-pager="#home-banner-pager"
data-cycle-pager-template="">';
$counter_slideshow=0;
while ($custom_query->have_posts()) : $custom_query->the_post();
$counter_slideshow++;
$image_url_full = px_get_post_img_src($post->ID, '810' ,'410');
if($image_url_full <> ''){
$slider_pagination[] = get_the_title();
?>
<article class="<?php echo $post->ID; ?>">
<?php if($image_url_full <> ''){?><img src="<?php echo $image_url_full;?>" alt=""><?php }?>
<div class="caption">
<?php
$rating = px_user_rating_display('blog-carousel-v2'.$counter_slideshow);
if(isset($rating) && $rating <> ''){
?>
<div class="heading-color cs-rating-heading">
<?php echo $rating;?>
</div>
<?php }?>
<div class="text">
<?php
$before_cat = '<span> ';
$categories_list = get_the_term_list ( get_the_id(), 'category', $before_cat, ', ', '</span>' );
if ( $categories_list ){
printf( __( '%1$s', 'Media News'),$categories_list );
}
?>
<h2><a href="<?php the_permalink(); ?>"><?php if ( strlen(get_the_title()) > 50){echo get_the_title();} else { the_title();} if ( strlen(get_the_title()) > 50) echo get_the_title();?></a></h2>
<?php px_posted_on(false,false,true,true,false,false);?>
</div>
</div>
</article>
<?php
}
endwhile;
echo '</div>';
if(is_array($slider_pagination) && count($slider_pagination)>0){
$pagination_no = 0;
echo '<div class="sliderpagination">
<ul id="home-banner-pager" class="banner-pager">';
while ($custom_query->have_posts()) : $custom_query->the_post();
$counter_slideshow++;
$image_small_full = px_get_post_img_src($post->ID, '150' ,'150');
if($image_small_full <> ''){
echo '<li>
<figure><img src="'.$image_small_full.'" alt=""></figure>';
?>
<div class="text">
<h2><a href="<?php the_permalink(); ?>"><?php if ( strlen(get_the_title()) > 50){echo get_the_title();} else { the_title();} if ( strlen(get_the_title()) > 50) echo "...";?></a></h2>
<?php
px_posted_on(false,false,true,true,true,false);
?>
</div>
<?php
echo '</li>';
}
endwhile;
echo '</ul></div>';
}
px_enqueue_cycle_script();
endif;
wp_reset_postdata();
?>
</div>
答案 0 :(得分:0)
看起来$ counter_slideshow变量可能就是你的问题所在。
如果您将条件设置为仅在希望它转到下一张幻灯片时递增它,则它不应前进到下一张幻灯片。
尝试在递增$ counter_slideshow变量之前设置一个标志:
//set flag to turn slide show on or off 1 = on 0 = off
$slideShowOn = 0;
然后你可以检查你的while循环,类似于:
//if the $slideShowOn equals 1 or on
if($slideShowOn === 1){//begin if then else
//increment the counter
$counter_slideshow++;
}
else{
//do something if the slideShowOn variable doesn't equal 1
}//end if then else