Highlighting works only in some search results
-
Hi,
while trying to customize search results I found the following problem:
Not all occurrences of keywords in search results are highlighted correctly.
You can find a screenshot of 4 search results that show what I mean here.The search keyword is Stiftskeller with nothing else before or after.
It is correctly highlighted in search results 1 and 4, but not in 2 and 3.
As you can see, I managed to enable highlighting inthe title
by replacing the_title byrelevanssi_the_title
in the template. Changing the snippet length also works.
All search results are custom post types while search results 1, 2 and 4 are one type and search result 3 is another.
In search results 1 and 4 the correctly highlighted keyword is in the post excerpt. The not correctly highlighted keyword in search result 2 is in a paragraph block in the post content and in search result 3 in the excerpt of a related post linked by a display-posts shortcode.
I also checked some more search results (not visible in the screenshot) where the keyword is correctly highlighted in the post title, a paragraph generated by a lazy block and the title of a related post also linked by a display-posts shortcode.As you can see, it is really confusing and I can not see the rule behind it.
But what I can say: searching again and rebuilding the index does not change anything.Any ideas what I can do or even try to get correctly highlighted keywords in the search results?
- The topic ‘Highlighting works only in some search results’ is closed to new replies.