我在一个页面上有两个循环,都包含一个计数器,每6篇文章就实现一个略有不同的代码。出于某种原因,尽管第二个循环有时在4项而不是6项之后实现不同的代码。
是否未正确重置回路?
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1">Most Popular</li>
<li class="tab-link" data-tab="tab-2">Recent</li>
</ul>
<div id="tab-1" class="tab-content current">
<div class="slider">
<div class="slide">
<?php
query_posts(\'meta_key=post_views_count&orderby=meta_value_num&order=DESC&post_type=atls_video&posts_per_page=-1\');
if (have_posts()) : while (have_posts()) : the_post();$count++; ?>
<?php if ($count%6== 0) : ?>
<div class="video-entry m-all t-1of2 d-1of3 cf">
<div class="video-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( \'video-thumb\' ); ?></a>
</div>
<div class="video-text">
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<a href="<?php the_permalink(); ?>" class="read-more">Read More</a>
</div>
</div>
</div>
<div class="slide">
<?php else : ?>
<div class="video-entry m-all t-1of2 d-1of3 cf">
<div class="video-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( \'video-thumb\' ); ?></a>
</div>
<div class="video-text">
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<a href="<?php the_permalink(); ?>" class="read-more">Read More</a>
</div>
</div>
<?php endif; ?>
<?php endwhile; endif; wp_reset_query();?>
</div>
<div style="clear:both;"></div>
</div>
</div>
<div id="tab-2" class="tab-content">
<div class="slider">
<div class="slide">
<?php
query_posts(\'orderby=date&order=DESC&post_type=atls_video&posts_per_page=-1\');
if (have_posts()) : while (have_posts()) : the_post();$count++; ?>
<?php if ($count%6== 0) : ?>
<div class="video-entry m-all t-1of2 d-1of3 cf">
<div class="video-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( \'video-thumb\' ); ?></a>
</div>
<div class="video-text">
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<a href="<?php the_permalink(); ?>" class="read-more">Read More</a>
</div>
</div>
</div>
<div class="slide">
<?php else : ?>
<div class="video-entry m-all t-1of2 d-1of3 cf">
<div class="video-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( \'video-thumb\' ); ?></a>
</div>
<div class="video-text">
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<a href="<?php the_permalink(); ?>" class="read-more">Read More</a>
</div>
</div>
<?php endif; ?>
<?php endwhile; endif; wp_reset_postdata();?>
</div>
<div style="clear:both;"></div>
</div>
</div>