可以运行多个嵌套WP_Queries 只要你reset_postdata()
让外环回到正轨。
$query_args = array (
\'posts_per_page\' => \'1\',
\'meta_key\' => $count_today,
\'orderby\' => \'meta_value_num\',
);
$outer_query = new WP_Query( $query_args );
while( $outer_query->have_posts() ) :
// conditional if
if( true ) {
// change the query arg in the inner loop
$query_args[ \'meta_key\' ] = \'something_else\';
}
// start an inner query with adjusted params
$inner_query = new WP_Query( $query_args );
// nested loop
while( $inner_query->have_posts() ) :
// ...
endwhile;
// After looping through a nested query, this function restores the $post global to the current post in this query.
$outer_query->reset_postdata();
endwhile;