• Resolved angyie

    (@angyie)


    Hi,

    I love the Relevanssi plugin! Although I am having one difficulty that I can’t solve. When I have searched for a word and been directed to the page I have the function highlight and scroll to the highlighted word applied and it works great unless the word that is searched is included in the accordion meny to the right. In that case it does not scroll to the highlighted word. Also I would prefer that relevanssi not highlights a word in the accordion meny only in the text on the page.

    How could I accomplish this?

    Thank you for all the help in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mikko Saari

    (@msaari)

    How have you implemented the “scroll to highlight” feature? Relevanssi doesn’t have that feature, so it’s coming from somewhere else.

    If the accordion menu is inside post content, Relevanssi cannot understand what content is regular post content and what belongs to a menu. You can add a filter function that runs after Relevanssi adds the highlighting and removes the unwanted highlights. Relevanssi runs the highlighting function on the_content hook on priority 11, so you can add a new function on the same hook on priority 12 to remove the unwanted highlights from the menus.

    Thread Starter angyie

    (@angyie)

    Hello!

    This is the code I use for “scroll to highlighted word”: https://codeshare.io/LjjZBK

    I found it here: https://www.relevanssi.com/knowledge-base/scroll-result-page-search-term/

    That sounds great to add a function to remove the accordion before the highlighting is added! The accordion already has an CSS-id, maybe I could use that? Should I use the relevanssi “relevanssi_clean_excerpt” function maybe? Also would you perhaps happen to be able to provide an exampel of how to write the code snippet? Just so I don’t mix it up.

    Thank you for the quick reply before!

    Plugin Author Mikko Saari

    (@msaari)

    Using a CSS ID is a fine way to recognise where the accordion is. I would recommend you get a developer to do the code for you – it’s not very hard, so someone can probably do it for you pretty quickly, but it’s complicated (and custom) enough that I can’t provide it here.

    The relevanssi_clean_excerpt() function is for other things; you need to create your own function that runs on the the_content hook on a priority 12 and removes the highlights Relevanssi added from the accordion.

    Thread Starter angyie

    (@angyie)

    Hi!

    Thank you for the quick reply!

    Okay I see, thats what I will do then.

    Thank you again for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Highlights words in accordion and does not scroll to the highlighted word’ is closed to new replies.