Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 29, 2022 13:42
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 searchwpgists/3bf55ce103173dd3382549afa899be63 to your computer and use it in GitHub Desktop.
Save searchwpgists/3bf55ce103173dd3382549afa899be63 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