[Plugin: Relevanssi – A Better Search] Incorrect excerpts for posts with tab characters
Relevanssi was accurately finding the posts in a site I manage, but for some of those posts the search excerpt it generated was incorrect in that it showed the beginning of the post text, while the word searched was near the end of the text, hence beyond the excerpt’s maximum length and thus cut out from it. Other posts had correct excerpts though.
Looking carefully at both kinds of posts, I noticed the problematic ones all had tab characters. So, in searching around Relevanssi’s code, I found the solution. Changing line 1624 from:
$content = preg_replace("/\n\r|\r\n|\n|\r/", " ", $content);
$content = preg_replace("/\n\r|\r\n|\n|\r|\t/", " ", $content);
makes the issue go away, and now search excerpts appear correctly for all posts.
I hope this helps!
- The topic ‘[Plugin: Relevanssi – A Better Search] Incorrect excerpts for posts with tab characters’ is closed to new replies.