Sort archive view with pre_get_posts hook
I solved this with a different approach. I used posts_join and posts_orderby filters. Do not forget to cast meta value as unsiged to avoid string ordering instead of int. //edit query join function hsa_story_join($join){ global $wpdb; $option = get_option(‘hsa_story_cats’); if(!is_admin() && is_category($option)) { $current_category = get_queried_object(); $join .= ” LEFT JOIN (SELECT post_id, meta_key, meta_value … Read more