Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
facetwp custom sort facet
/**
* custom sort order for a facet, this orders by facet_display_value but facet_value could also be used
**/
add_filter( 'facetwp_facet_orderby', function( $orderby, $facet ) {
if ( 'colors' == $facet['name'] ) { // change colors to the name of the facet
$orderby = "FIELD(f.facet_display_value, 'Blue','Green','Red', 'Gray')";
}
return $orderby;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.