SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

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
// @link https://searchwp.com/documentation/rest-api/
// 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
// @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 );

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
// @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 );

Create a Better WordPress Search Experience Today

Never lose visitors to unhelpful search results again. SearchWP makes creating your own smart WordPress search fast and easy.

Get SearchWP Now
Multiple Search Engines Icon