searchwp\native\short_circuit
Da: 4.0.0
Indice
Controlla se SearchWP sovrascrive le ricerche native di WordPress.
Parametri
| Tipo | Parametro | Predefinito | Da |
|---|---|---|---|
| Booleano | $enabled |
false |
4.0.0 |
| \SearchWP\Query | $query |
La Query in esecuzione | 4.0.0 |
Esempi
All hooks should be added to your custom SearchWP Customizations Plugin.
Impedisci a SearchWP di fornire risultati di ricerca quando esiste un parametro URL specifico
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 ); |

