I also tried this approach, but this crashed the site with a fatal error:
function tas_pre_get_posts( $query ) {
// do not modify queries in the admin
if( is_admin() ) {
return $query;
}
// only modify queries for 'post' post type
if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'post' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'tas_album_order');
$query->set('order', 'DESC');
}
// return
return $query;
}
add_action('pre_get_posts', 'tas_pre_get_posts');
It was a subfield, and a number field. I changed it to be a top level field and it didn’t work there either.