Available since: 1.0.6
searchwp_max_search_terms
View Parameters »To respect performance, SearchWP limits the number of search terms that are considered when running searches. You can modify that limit with this filter.
Example: To limit ALL search queries to 5 terms, add the following to your active theme’s functions.php
:
<?php | |
function my_searchwp_max_search_terms( $maxTerms, $engine ) { | |
// limit to 5 search terms | |
return 5; | |
} | |
add_filter( 'searchwp_max_search_terms', 'my_searchwp_max_search_terms', 10, 2 ); |
Example: To limit all supplemental search engine search queries to 7 terms, add the following to your active theme’s functions.php
:
<?php | |
function my_searchwp_max_search_terms_supplemental( $maxTerms, $engine ) { | |
// limit to 7 search terms for all supplemental search engines, not the default | |
return 7; | |
} | |
add_filter( 'searchwp_max_search_terms_supplemental', 'my_searchwp_max_search_terms_supplemental', 10, 2 ); |
Example: To limit the number of terms accepted for search queries to a single supplemental search engine, add the following to your active theme’s functions.php
:
<?php | |
function my_searchwp_max_search_terms_my_search_engine( $maxTerms ) { | |
// limit to 8 search terms for My Supplemental Search Engine ONLY | |
return 8; | |
} | |
add_filter( 'searchwp_max_search_terms_my_search_engine', 'my_searchwp_max_search_terms_my_search_engine', 10, 2 ); |
Note: You can use any combination of these filters to achieve the same effect, it comes down to developer preference.
Parameters
Parameter | Type | Description |
---|---|---|
$maxTerms |
Integer |
The search term limit |
$engine |
String |
The search engine in use. Not applicable to the |