searchwp\synonyms
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.
Parameters
Type | Parameter | Default | Since | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Array |
$synonyms
|
4.0.0 |
|||||||||||||
Array |
$args
|
4.0.0 |
Examples
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
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 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 ); |