How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
to sort the posts by a meta field you need to have this field in meta_query and in orderby like this $query_args = array( ‘post_type’ => ‘MY_POSTTYPE_NAME’, ‘post_per_page’ => -1, ‘meta_query’ => array( ‘show_post_query’ => array( ‘key’ => ‘SHOW_POST’, ‘value’ => ‘1’ ), ‘MY_FIELD_NAME__order_by’ => array( ‘key’ => ‘MY_FIELD_NAME’, ‘type’ => ‘NUMERIC’, ‘compare’ => ‘NUMERIC’, … Read more