如Jan所述query_posts()
替换此$wp_query
对象
所以你能做的就是WP_Query
并存储旧的$wp\\u查询对象:
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query($args);
while ( $wp_query->have_posts() ) : $wp_query->the_post();
Do what you need
endwhile;
$wp_query = $temp;
或使用新变量:
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post();
Do what you need
endwhile;