SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

searchwp\native\short_circuit

Since: 4.0.0

Table of Contents

Control whether SearchWP overrides native WordPress searches.

Parameters

Type Parameter Default Since
Boolean $enabled false 4.0.0
\SearchWP\Query $query The Query being run 4.0.0

Examples

All hooks should be added to your custom SearchWP Customizations Plugin.

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 );

How to use this code