Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active March 29, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/755e7802c5061f228428d9ba3ef591cf to your computer and use it in GitHub Desktop.
Save mgibbs189/755e7802c5061f228428d9ba3ef591cf to your computer and use it in GitHub Desktop.
<?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