Search term in middle of word not highlighted by relevanssi_the_title

That is correct. The middle-of-the-word searching only applies to search queries, it has no effect on highlighting. There’s currently no way to change that; middle-of-the-word highlighting is not available, because with short words, it creates very messy results.

I can throw in a filter hook in the next version so that middle-of-the-word highlights can be enabled that way.

Thanks for confirming the behavior @msaari

I appreciate ours is an edge use case, but if a filter could be made available to enable this it would be great please. We are using relevanssi on a REST api method to quickly filter lots of text based on very fuzzy matching so middle word highlight would really enhance this. Thank you in advance!

If you want a hotfix, modify /lib/excerpts-highlights.php and add

$regex = apply_filters( 'relevanssi_highlight_regex', $regex, $pr_term );

before this line:

$content .= ' ';

Then you can use this filter hook to modify the regex:

add_filter( 'relevanssi_highlight_regex', function( $regex, $pr_term ) {
  return "/($pr_term)/iu";
}, 10, 2 );

Hotfix works a treat. Thank you!

Amazing & speedy support @msaari … I very much appreciate it.


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer