Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by PHPXCODE ( 8 years ago )
add_action( 'pre_get_posts', 'wpse183601_filter_category_query' );
function wpse183601_filter_category_query( $query ) {
// only modify front-end category archive pages
if( is_category() && !is_admin() && $query->is_main_query() ) {
$today = current_time('Y-m-d');
//query 1
$args1 = array(
'meta_key' => 'Окончание',
'meta_type' => 'DATE',
'orderby'=> 'meta_value',
'order' => 'ASC',
'meta_query' => array(
'key' => 'Окончание',
'compare' => '>=',
'meta_type' => 'DATE',
'value' => $today
)
);
$args2 = array(
'meta_key' => 'Окончание',
'meta_type' => 'DATE',
'orderby'=> 'meta_value',
'order' => 'ASC',
'meta_query' => array(
'key' => 'Окончание',
'compare' => '<',
'meta_type' => 'DATE',
'value' => $today
)
);
global $wp_query;
$query1 = new WP_Query($args1);
$query2 = new WP_Query($args2);
$wp_query = new WP_Query();
$wp_query->posts = array_merge( $query1->posts, $query2->posts );
$wp_query->post_count = $query1->post_count + $query2->post_count;
}
}
Revise this Paste