apply_filters( 'relevanssi_block_one_letter_searches', boolean $block )
Determines whether one-letter search terms are allowed or not.
Parameters
$block
(boolean) If true
, one-letter search terms are not allowed. If false
, they are allowed. Default true
.
More information
By default, Relevanssi blocks all one-letter search terms from the search, no matter what the minimum word length setting is. If you want to allow one-letter search terms, return false
for this filter hook (here’s how you add custom functions):
add_filter( 'relevanssi_block_one_letter_searches', '__return_false' );
Even if fuzzy matching is enabled in the settings, it’s still disabled when a one-letter search is done because a fuzzy search for a single letter generally tends to return the whole database. If you want to get fuzzy matching for one-letter searches and know what you’re doing, this is how you can make it work:
add_filter( 'relevanssi_term_where', function( $where ) { $where = preg_replace( "/relevanssi.term = '(.)'/", "relevanssi.term LIKE '%$1%'", $where ); // inside-word matching $where = preg_replace( "/relevanssi.term = '(.)'/", "( relevanssi.term LIKE '$1%' OR relevanssi.term_reverse LIKE '$1%' )", $where ); // match beginning or end return $where; } );
If you want to allow one-letter highlights in excerpts, see relevanssi_allow_one_letter_highlights
.