您可以尝试以下操作(未经测试):
Setup the query arguments #1: (today)
//-----------------
// Query part #1:
//-----------------
$args1 = array(
\'post_type\' => \'post\',
\'orderby\' => \'comment_count\',
\'ignore_sticky_posts\' => 1,
\'date_query\' => array(
array(
\'after\' => date(\'Y-m-d\'),
),
\'inclusive\' => true,
)
);
Setup the query arguments #2: (!today)
//-----------------
// Query part #2:
//-----------------
$args2 = array(
\'post_type\' => \'post\',
\'orderby\' => \'comment_count\',
\'ignore_sticky_posts\' => 1,
\'date_query\' => array(
array(
\'before\' => date(\'Y-m-d\'),
),
\'inclusive\' => false,
)
);
Then we combine it:
//---------------------------
// Combined queries #1 + #2:
//---------------------------
$args = array(
\'posts_per_page\' => 5,
\'paged\' => ( $paged = get_query_var( \'paged\' ) ) ? $paged : 1 ,
\'sublimit\' => 1000,
\'args\' => array( $args1, $args2 ),
);
$results = new WP_Combine_Queries( $args );
我们在哪里使用实验
WP_Combine_Queries
班
from here.
它当前正在使用UNION
但你可能想使用UNION ALL
相反
GitHub:
该插件现在在GitHub上可用
here.