SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

searchwp\query\partial_matches\tokens

Since: 4.0.0

Table of Contents

Manipulate partial match tokens during partial match logic application.

Parameters

Type Parameter Default Since
String[] $partial_tokens Partial match tokens found by SearchWP 4.0.0
Array $args
Key Type Value
args Array Partial match logic arguments, array with keys: keyword_tokens, exact_matches, query, partial
tokens Array Tokens for this search
query \SearchWP\Query The Query for this search
4.0.0

Examples

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

Always add 'coffee' to partial matches even if it's not

If you would like to always add the word “coffee” to the list of partial matches:

<?php
// Always add 'coffee' to partial matches even if it's not.
add_filter( 'searchwp\query\partial_matches\tokens', function( $partial_match_tokens, $args ) {
$partial_match_tokens[] = 'coffee';
return $partial_match_tokens;
}, 10, 2 );

How to use this code