searchwp\native\short_circuit
Seit: 4.0.0
Steuern Sie, ob SearchWP native WordPress-Suchen überschreibt.
Parameter
| Typ | Parameter | Standard | Seit |
|---|---|---|---|
| Boolean | $enabled |
false |
4.0.0 |
| \SearchWP\Query | $query |
Die ausgeführte Abfrage | 4.0.0 |
Beispiele
All hooks should be added to your custom SearchWP Customizations Plugin.
Verhindern Sie, dass SearchWP Suchergebnisse liefert, wenn ein bestimmter URL-Parameter vorhanden ist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 ); |

