-
-
Save searchwpgists/f4dec5c63e1ae9e0c102e29a01d25fa5 to your computer and use it in GitHub Desktop.
Customize SearchWP stopwords per Engine
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 | |
/** | |
* Customize SearchWP stopwords per Engine. | |
*/ | |
// Optional: remove all Stopwords so you can add only unique Stopwords per Engine. | |
add_filter( 'searchwp\stopwords', '__return_empty_array' ); | |
// Add unique stopword(s) for a single SearchWP Engine. | |
add_filter( 'searchwp\query\search_string', function( $search_string, $query ) { | |
// Remove "apple" and "orange" for my_engine searches. | |
if ( 'my_engine' === $query->get_engine() ) { | |
$search_string = str_replace( [ 'apple', 'orange' ], '', $search_string ); | |
} | |
return $search_string; | |
}, 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment