searchwp\native\short_circuit
4.0.0以降
SearchWPがWordPressのネイティブ検索をオーバーライドするかどうかを制御します。
パラメータ
| タイプ | パラメータ | デフォルト | 提供開始 |
|---|---|---|---|
| ブール値 | $enabled |
false |
4.0.0 |
| \SearchWP\Query | $query |
実行中のクエリ | 4.0.0 |
例
すべてのフックはカスタムのSearchWP カスタマイズプラグインに追加する必要があります。
特定のURLパラメータが存在する場合にSearchWPが検索結果を提供しないようにする
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 ); |

