2014-11-23 107 views
-1

你好,我试图禁用这个幻灯片自动移动。你可以帮忙吗? 我尝试了几乎所有我能做的事,但我无法做到。这是functions.php文件的一部分,它包括脚本我非常希望放在正确的代码jquery幻灯片禁用自动播放

<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

它看起来像$ 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 
+0

只是没有工作,以我或我没有做对! – 2014-11-23 21:36:53

+0

你有链接到实时预览,所以我可以帮助调试你的脚本? – 2014-11-24 00:45:34