Use this code instead-
$supplierArgs = array(
'post_type' => 'service_providers',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'service_provider_tier',
'value' => 'G',
'compare' => '='
),
array(
'key' => 'service_provider_tier',
'value' => 'S',
'compare' => '='
),
array(
'key' => 'service_provider_tier',
'value' => 'B',
'compare' => '='
),
),
'orderby' => 'meta_value',
'meta_key' => 'service_provider_tier',
'meta_type' => 'CHAR',
'order' => 'ASC'
);
$query = new WP_Query( $supplierArgs );
This approach uses meta_value
to order the posts and assigns the custom field service_provider_tier
to meta_key
. It orders the results by the value of the service_provider_tier
meta key. If you need a custom order (Gold, Silver, Basic), you may have to manipulate the query results after fetching them or use a custom sorting function.