Created
August 18, 2017 16:03
-
-
Save djrmom/d4654a8f1cf443ea5150049dd06deb2c to your computer and use it in GitHub Desktop.
facetwp custom sort facet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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