在Robert和Pieter的建议下,我使用WP\\u Query而不是Query\\u posts重写了循环。现在可以了。谢谢各位。
代码如下:
<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
$count = 0;
$query = new WP_Query(
array(
\'meta_key\' => \'post_views_count\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'DESC\',
\'post_type\' => \'atls_video\',
\'posts_per_page\' => \'-1\'
) );
while ( $query->have_posts() ) : $query->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; ?>
<?php wp_reset_postdata();?>
</div>
<div style="clear:both;"></div>
</div>
</div>
<div id="tab-2" class="tab-content">
<div class="slider">
<div class="slide">
<?php
$count = 0;
$query = new WP_Query(
array(
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'post_type\' => \'atls_video\',
\'posts_per_page\' => \'-1\'
) );
while ( $query->have_posts() ) : $query->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; wp_reset_postdata();?>
</div>
<div style="clear:both;"></div>
</div>
</div>