In a taxonomy archive page I want change the order my different custom post appear.
Basically I am looking to achieve this order:
I have added a pre_get_posts filter in my function page which looks like this:
function fwp_archive_per_page( $query ) {
if ( is_tax() ) {
$query->set('meta_query',
array(
'relation' => 'OR',
array(
'key' => 'date_of_event',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'date_of_event',
'value' => date("Ymd"),
'compare' => '>',
),
array(
'key' => 'date_of_event',
'value' => date("Ymd"),
'compare' => '<',
),
)
);
$query->set('orderby',
array(
'meta_value_num' => 'DESC',
'title' => 'ASC',
)
);
//$query->set('posts_per_page', -1);
}
}
add_filter( 'pre_get_posts', 'fwp_archive_per_page' );
This gives me this order.
Is it possible to achieve this by filtering the existing archive query?
Thank you.