searchwp\native\short_circuit
Desde: 4.0.0
Sumário
Controlar se o SearchWP substitui as pesquisas nativas do WordPress.
Parâmetros
| Tipo | Parâmetro | Padrão | Desde |
|---|---|---|---|
| Booleano | $enabled |
falso |
4.0.0 |
| \SearchWP\Query | $query |
A consulta que está sendo executada | 4.0.0 |
Exemplos
Todos os hooks devem ser adicionados a seu plugin personalizado SearchWP Customizations Plugin.
Impedir que o SearchWP forneça resultados de pesquisa quando um parâmetro de URL específico existir
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 ); |

