Actually this private function in my function.php works, BUT: i often get Error 500 by the Server on the first load, often it renders AFTER reloading the page.
## change the sorting order on archive pages: order archive by title
add_action( 'pre_get_posts', 'gpsp_change_sort_order');
function gpsp_change_sort_order($query) {
if(is_archive() && $query->is_main_query()) :
$query->set(
'meta_query',
array(
'relation' => 'OR',
array( 'key' => 'ausgabe', 'value' => '', 'compare' => 'EXISTS', 'type' => 'NUMERIC' ),
array( 'key' => 'position', 'value' => '', 'compare' => 'EXISTS', 'type' => 'NUMERIC' )
));
$query->set( 'orderby', 'meta_value position' );
$query->set( 'meta_key', 'ausgabe' );
$query->set( 'order', 'ASC' );
endif;
};
Is anyone expert enought to explain me that error?