facetwp order by facet_value

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** order by facet value (value shown in url on selection) instead of display value (label) **/

add_filter( ‘facetwp_facet_orderby’, function( $orderby, $facet ) {
if ( ‘day_of_week’ == $facet[‘name’] ) {
$orderby = ‘FIELD(f.facet_value, “monday”, “tuesday”, “wednesday”, “thursday”, “friday”, “saturday”, “sunday”)’;
}
return $orderby;
}, 10, 2 );
{{/gist}}