searchwp\native\short_circuit
Depuis : 4.0.0
Table des matières
Contrôlez si SearchWP remplace les recherches natives de WordPress.
Paramètres
| Type | Paramètre | Défaut | Depuis |
|---|---|---|---|
| Booléen | $enabled |
faux |
4.0.0 |
| \SearchWP\Query | $query |
La requête en cours d'exécution | 4.0.0 |
Exemples
All hooks should be added to your custom SearchWP Customizations Plugin.
Empêcher SearchWP de fournir des résultats de recherche lorsqu'un paramètre d'URL spécifique existe
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 ); |

