Since: 4.0.0

Table of Contents

SearchWP uses Synonyms to both optimize the index and increase relevancy of search results.

The primary method of customizing the list of Synonyms is by way of the Settings tab of the SearchWP Settings screen. You can however programmatically filter Synonyms as well.


Type Parameter Default Since
Array $synonyms
Key Type Value
sources String Search term(s)
synonyms String Synonym(s) for search term(s)
replace Boolean Whether synonym(s) should replace search term(s)
Array $args
Key Type Value
search_string String Submitted search string
query \SearchWP\Query The Query taking place


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

Add Synonym to existing Synonyms

Append a custom Synonym to the UI-defined set of Synonyms on the Settings tab of the SearchWP Settings screen

// Add Synonym to existing Synonyms in SearchWP.
add_filter( 'searchwp\synonyms', function( $synonyms, $args ) {
$synonyms[] = [
'sources' => 'seo',
'synonyms' => 'search engine optimization',
'replace' => false,
return $synonyms;
}, 20, 2 );

How to use this code