SearchWP & WordPress REST API
SearchWPは、検索を実行する際にWordPressのREST APIと統合されます。
注意: REST API検索が実行されると、SearchWPはネイティブのWordPress検索リクエストの場合と同様に、デフォルトエンジンを使用します。
REST APIは、'リンク追加'ダイアログでの検索を含む、WordPressコアの一部の場所で使用されます。SearchWPエンジンのいずれかを管理画面の検索中に使用するように設定している場合、そのエンジンがこの場合に使用されます。これは、エンジンの設定によっては望ましくない動作につながる可能性があります。
SearchWP REST API統合を無効にする
このフックを使用して、SearchWPがREST APIと一切統合しないようにすることができます。
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Disable default SearchWP REST API Integration. | |
| add_filter( 'searchwp\rest', '__return_false' ); |
RESTリクエストに使用されるエンジンをカスタマイズする
該当するRESTリクエストに使用されるSearchWPエンジンをカスタマイズするには:
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Customize the SearchWP Engine used for applicable REST requests. | |
| add_filter( 'searchwp\rest\engine', function( $engine, $args ) { | |
| return 'my_rest_engine_name'; | |
| }, 10, 2 ); |
RESTリクエストに使用されるSearchWPクエリ引数をカスタマイズする
該当するRESTリクエストに使用されるSearchWPクエリ引数をカスタマイズするには:
All hooks should be added to your custom SearchWP Customizations Plugin.
| <?php | |
| // @link https://searchwp.com/documentation/rest-api/ | |
| // Customize the SearchWP Query arguments used for REST requests. | |
| add_filter( 'searchwp\rest\args', function( $args, $params ) { | |
| // $args are sent to \SWP_Query after this. | |
| // @link https://searchwp.com/documentation/classes/swp_query/ | |
| return $args; | |
| }, 10, 2 ); |

