2014-11-23 158 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