SearchWP Documentation

インストールガイドを表示したり、ナレッジベースを参照したり、SearchWPの多くのフックについて確認したりできます。

searchwp\native\short_circuit

4.0.0以降

SearchWPがWordPressのネイティブ検索をオーバーライドするかどうかを制御します。

パラメータ

タイプ パラメータ デフォルト 提供開始
ブール値 $enabled false 4.0.0
\SearchWP\Query $query 実行中のクエリ 4.0.0

All hooks should be added to your custom SearchWP Customizations Plugin.

特定のURLパラメータが存在する場合にSearchWPが検索結果を提供しないようにする

<?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 );

このコードの使用方法