mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-28 11:22:21 +08:00
https://gist.facetwp.com/gist/facetwp-autocomplete-facet-return-only-results-matching-the-exact-value-entered/
11 lines
368 B
Text
11 lines
368 B
Text
add_filter( 'facetwp_wpdb_sql', function( $sql, $facet ) {
|
|
|
|
if ( 'my_autocomplete' == $facet['name'] ) { // Replace 'my_autocomplete' with the name of your Autocomplete facet
|
|
global $wpdb;
|
|
$sql = $wpdb->remove_placeholder_escape( $sql );
|
|
$sql = str_replace(" LIKE '", " = '", $sql);
|
|
$sql = str_replace("%", "", $sql);
|
|
}
|
|
|
|
return $sql;
|
|
}, 10, 2 );
|