Last active
March 29, 2019 23:55
-
-
Save mgibbs189/755e7802c5061f228428d9ba3ef591cf to your computer and use it in GitHub Desktop.
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
<?php | |
/* Remove "INCH" from the raw value */ | |
add_filter( 'facetwp_index_row', function( $params, $class ) { | |
if ( 'barrel_length' == $params['facet_name'] ) { | |
// format the value | |
$params['facet_value'] = preg_replace("/[^0-9.]/", '', $params['facet_value']); | |
} | |
return $params; | |
}, 10, 2 ); | |
/* Sort numerically */ | |
add_filter( 'facetwp_facet_orderby', function( $orderby, $facet ) { | |
if ( 'barrel_length' == $facet['name'] ) { | |
$orderby = 'f.facet_value+0 ASC'; | |
} | |
return $orderby; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment