FacetWP – match beginning of word with autocomplete LIKE

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add the following to your (child) theme’s functions.php

add_filter( ‘facetwp_wpdb_sql’, function( $sql, facet ) {
if ( ‘annuaire_specialite’ == $facet[‘name’] ) {
$sql = str_replace( ‘LIKE %’, ‘LIKE ‘, $sql );
}
return $sql;
}, 10, 2 );

{{/gist}}