searchwp\query\logic\{$type}\strict
Since: 4.0.0
Table of Contents
Influence how SearchWP works through its various logic passes when performing searches.
By default SearchWP will iterate through a series of logic passes when performing searches in this order:
phrase
(i.e. “quoted”, sentence searches)and
(i.e. all search terms present in all results)or
(i.e. any search terms present in any result)
After each pass, SearchWP will evaluate whether it should continue with the next logic pass dependent on whether any results were returned.
If zero results were returned for the current logic pass, the next will be utilized.
This hook will facilitate ‘breaking out’ of this loop and force an empty results set at the current logic pass.
Parameters
Type | Parameter | Default | Since |
---|---|---|---|
Boolean | $enabled |
false |
4.0.0 |
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Force AND logic
With this snippet in place SearchWP will execute only phrase logic (when enabled) followed by AND
logic. If no results are returned an empty results set will be returned as opposed to repeating the search using OR
logic and returning those results.
<?php | |
// Force SearchWP to use AND logic and not fall back to OR logic. | |
add_filter( 'searchwp\query\logic\and\strict', '__return_true' ); |