SearchWP

SearchWP & WordPress REST API

SearchWP will integrate with WordPress’ REST API when performing searches.

Note: When a REST API search is performed, SearchWP will use its Default Engine as it does for native WordPress search requests.

The REST API is used by WordPress core in some places, including when searching in the ‘Add Link’ dialog. If you have set one of your SearchWP Engines to be used during Admin searches, that Engine will be used in this case. This may result in undesired behavior depending on your Engine configuration.

Disable SearchWP REST API Integration

You can use this hook to prevent SearchWP from integrating with the REST API at all:

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

<?php
// Disable default SearchWP REST API Integration.
add_filter( 'searchwp\rest', '__return_false' );

Customize the Engine used for REST requests

To customize the SearchWP Engine used for applicable REST requests:

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

<?php
// Customize the SearchWP Engine used for applicable REST requests.
add_filter( 'searchwp\rest\engine', function( $engine, $args ) {
return 'my_rest_engine_name';
}, 10, 2 );

Customize the SearchWP Query arguments used for REST requests

To customize the SearchWP Query arguments used for applicable REST requests:

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

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