jenny-r
8/18/2017 - 4:03 PM

facetwp custom sort facet

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 );