Available since: 1.3.6
searchwp_short_circuit
View Parameters »If you are working on a very custom project and want to prevent SearchWP from injecting it’s own search results, you can do so by telling it to short circuit. Add the following to your theme’s functions.php:
This file contains 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 | |
add_filter( 'searchwp_short_circuit', '__return_true' ); |
With that filter in place SearchWP will not inject search results into the native WordPress search. You can then do the following to retrieve search results from SearchWP and do what you’d like with them:
This file contains 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 | |
$results = SWP()->search( 'default', 'my search terms' ); | |
// returns an array of post objects |
Parameters
Parameter | Type | Description |
---|---|---|
$short_circuit |
Boolean |
Whether SearchWP will short circuit |
$searchwp |
Object |
The SearchWP instance |