您不应多次使用query\\u帖子。这将产生错误。你必须使用wp_query
.
以下是wordpress codex中的内容:
query_posts( is meant for altering the main loop. 使用query\\u posts()后,将更改与post相关的全局变量和模板标记。在调用query\\u posts()后调用的条件标记也将被更改-这可能是也可能不是预期的结果。
http://codex.wordpress.org/Function_Reference/query_posts
<?php $query_one = new WP_Query(\'cat=3&showposts=1\'); ?>
<?php while($query_one->have_posts()) : ?>
<?php
$postcount++;
if( ($postcount % 2) == 0 ) : // skip \'even\' posts
$wp_query->next_post();
else :
?>
<?php $query_one->the_post(); ?>
<?php if ( function_exists( \'get_the_image\' ) ) { get_the_image( array( \'custom_key\' => array( \'post_thumbnail\' ), \'default_size\' => \'full\',\'image_class\' => \'alignleft\', \'width\' => \'120\', \'height\' => \'120\' ) ); } ?>
<?php endif; ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // Important to reset it when done ?>
</div>
<?php $postcount = 0; rewind_posts(); ?>
<div class="even-column">
<?php $query_two = new WP_Query(\'cat=3&showposts=2\'); ?>
<?php while($query_two->have_posts()) : ?>
<?php
$postcount++;
if( ($postcount % 2) != 0 ) : // skip \'odd\' posts
$wp_query->next_post();
else :
?>
<?php $query_two->the_post(); ?>
<?php if ( function_exists( \'get_the_image\' ) ) { get_the_image( array( \'custom_key\' => array( \'post_thumbnail\' ), \'default_size\' => \'full\', \'image_class\' => \'alignleft\', \'width\' => \'60\', \'height\' => \'60\' ) ); } ?>
<?php endif; ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // After every wp_query ?>
</div>
您可以在此处阅读更多信息:
http://codex.wordpress.org/Class_Reference/WP_Query