Filter each search term for a SearchWP search
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 | |
function my_searchwp_term_in( $term, $engine, $original_term ) { | |
// $term is an array because other filters may have broadened the search already (e.g. LIKE Terms extension) | |
// $original_term is the original, unaltered term | |
// if someone searched for "NYC" we need to convert it to "New York City" | |
// because we never write "NYC" and always write "New York City" | |
if ( 'nyc' == strtolower( $original_term ) ) { | |
$term = explode( ' ', 'New York City' ); // keep it an array | |
} | |
return $term; | |
} | |
add_filter( 'searchwp_term_in', 'my_searchwp_term_in' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment