Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created July 25, 2019 12:18
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/717396d8364198ffe6119780aaef6a92 to your computer and use it in GitHub Desktop.
Save jchristopher/717396d8364198ffe6119780aaef6a92 to your computer and use it in GitHub Desktop.
Conditionally force OR logic in SearchWP based on search query
<?php
// If someone searches for "soccer ball" force OR logic in SearchWP.
add_filter( 'searchwp_terms', function( $query, $engine ) {
if ( false !== strpos( strtolower( $query ), 'soccer ball' ) ) {
add_filter( 'searchwp_and_logic', '__return_false' );
}
return $query;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment