Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created December 8, 2013 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/7852506 to your computer and use it in GitHub Desktop.
Save jchristopher/7852506 to your computer and use it in GitHub Desktop.
Customize the query submitted to SearchWP before the search actually takes place
<?php
// if your visitors commonly misspell "soccer" as "socer" you can fix that for them
function my_parse_searchwp_terms( $query, $engine ) {
if( false !== strpos( strtolower( $query ), 'socer' ) ) {
$query = str_replace( 'socer', 'soccer', strtolower( $query ) );
}
return $query;
}
add_filter( 'searchwp_terms', 'my_parse_searchwp_terms', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment