Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created March 26, 2020 16:53
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/0f7aa98ab1dd814e21c185f66d3a9da9 to your computer and use it in GitHub Desktop.
Save jchristopher/0f7aa98ab1dd814e21c185f66d3a9da9 to your computer and use it in GitHub Desktop.
Prevent SearchWP from providing search results when a specific URL parameter exists
<?php
// Prevent SearchWP from providing search results when a specific URL parameter exists.
add_filter( 'searchwp\native\short_circuit', function( $enabled, $query ) {
// If 'my-query-var' is set, short circuit SearchWP.
if ( isset( $_GET['my-query-var'] ) ) {
return true;
}
return $enabled;
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment