searchwp\native\short_circuit
Desde: 4.0.0
Tabla de contenidos
Controla si SearchWP anula las búsquedas nativas de WordPress.
Parámetros
| Tipo | Parámetro | Predeterminado | Desde |
|---|---|---|---|
| Booleano | $enabled |
false |
4.0.0 |
| \SearchWP\Query | $query |
La consulta que se está ejecutando | 4.0.0 |
Ejemplos
All hooks should be added to your custom SearchWP Customizations Plugin.
Evitar que SearchWP proporcione resultados de búsqueda cuando exista un parámetro de URL específico
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 ); |

