apply_filters( 'relevanssi_excerpt_query', string $query )

Filters the search query before it is tokenized in excerpt creation.


(string) The search query.

More information

Relevanssi needs the search query in order to create excerpts that feature the search terms. The query string is passed through this filter before it is tokenized and the tokens used to create the excerpts. If you need to modify the search query before tokenization, this filter can be used.

This is another of those filter functions where I’m struggling to come up with real-life examples. This filter might be useful if you modify the search query somehow, in a way that otherwise wouldn’t be reflected in the excerpt-building. I’m not sure what that would be… so this likely isn’t the most useful filter hook. But it’s there, and please me know if you have a use case for this filter hook.

add_filter( 'relevanssi_excerpt_query', 'rlv_edit_excerpt_query' );
function rlv_edit_excerpt_query( $query ) {
  // Edit the $query somehow.
  return $query;