Skip to main contentSkip to footer

relevanssi_truncate_search_queries

Controls the maximum length of the search queries.

apply_filters( 'relevanssi_truncate_search_queries', int $length )

Parameters

$length
(int) The maximum length of the query.

More information

By default, there’s no maximum length for the search query (in practise, there is, but it’s so big it doesn’t matter). Very long queries can be heavy on the server and are usually spam queries. Real humans don’t usually do long queries.

You can use this filter hook to truncate the search queries to a specific length. If this filter hook returns an integer, each query will be truncated to that many characters.

add_filter( 'relevanssi_truncate_search_queries', function() { return 50; } );