Skip to content

Instantly share code, notes, and snippets.

View ahegyes's full-sized avatar

Tony Hegyes ahegyes

View GitHub Profile
@ahegyes
ahegyes / gist:4ecfbc4275ffbf38543dd6d71015285e
Created May 26, 2021 08:50
FacetWP fuzzy autocomplete
add_filter( 'query', function( $query ) {
if ( false !== strpos( $query, 'facet_display_value LIKE' ) ) {
preg_match( "/LIKE '%(.*?)%'/s", $query, $matches );
$keywords = $matches[1];
if ( ! empty( $keywords ) ) {
$old_where = "facet_display_value LIKE '%$keywords%'";
$new_where = array();
$keywords_boom = explode( ' ', $keywords );