You can try the following (untested):
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 );
where we use the experimental WP_Combine_Queries
class from here.
It’s currently using UNION
but you might want to use UNION ALL
instead.
GitHub:
The plugin is now available on GitHub here.