This Documentation is for SearchWP Version 3

Available since: 2.0.3


View Parameters »

If you would like to manipulate the submitted search terms in any way, this hook can do that. This hook is fired once forĀ each term in a search phrase. To use this hook, add something like the following to your theme’s functions.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' );
view raw gistfile1.php hosted with ❤ by GitHub


Parameter Type Description
$term Array

Array containing the search term. It’s an array because search term broadening may need to take place, but be kept to search tokens.

$engine String

The search engine in use

$original_prepped_term String

The original (unaltered by other uses of this filter) search term as a string