Available since: 1.4.2
searchwp_custom_stemmer
View Parameters »Note: You should review this filter before installing SearchWP
SearchWP ships with a single language stemmer that’s used to generate keyword stems for searches. If you run a non-English website and would prefer to use your own stemmer, this filter makes that possible.
Example: To tell SearchWP to utilize your own stemmer when generating keyword stems, add the following to your active 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 | |
// Tell SearchWP we have a stemmer | |
add_filter( 'searchwp_keyword_stem_locale', '__return_true' ); | |
function my_searchwp_custom_stemmer( $unstemmed ) { | |
$stemmer = new My_Stemmer(); // use your own custom stemmer | |
$stemmed = $stemmer->get_stem( $unstemmed ); // get the stem | |
return $stemmed; | |
} | |
add_filter( 'searchwp_custom_stemmer', 'my_searchwp_custom_stemmer' ); |
Parameters
Parameter | Type | Description |
---|---|---|
$unstemmed |
String |
The unstemmed keyword |