facetwp meta query order by field

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

$args = array(
‘level’ = > array(
‘key’ => ‘_hmd_practice_membership_level’,
‘value’ => array( ‘gold’, ‘silver’, ‘bronze’, ‘basic’, ‘free’ ),
‘compare’ => ‘IN’
)
);

$query->set( ‘meta_query’, $args );
$query->set( ‘orderby’, ‘level’ );
$query->set( ‘order’, FIELD(‘gold’, ‘silver’, ‘bronze’, ‘basic’, ‘free’) );
{{/gist}}