• Resolved keithfarmer

    (@keithfarmer)


    Hi
    This is an excellent plugin but I am having trouble getting the highlighting of search terms to work.
    Relevanssi in conjunction with Search & Filter to provide the search terms. Divi 3, Easy Digital Downloads, Restrict Content Pro.

    The results page is a loop brought in via shortcode. It is the one provided by “Search & Filter”. Link to Pastebin for the search results pastebin.com/Q2U6bkPy .
    The results code uses the_excerpt(), Relevanssi is enabled in “Search & Filter”. And I think I checked the right options in Revelanssi settings.
    Checked create custom snippets,
    selected “strong” for highlight type and
    allowed tags excerpts ,
    show breakdown of search hits, breakdown format default.

    Do I need to add php to the search results loop?

    Many thanks for any help.

    Keith

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

    (@msaari)

    That template file is from Search & Filter Pro, not Divi, so is it really the one used in your theme? If it is, then yes, it should work just fine.

    If you change the custom snippet settings in Relevanssi, do the excerpts on the search results page change?

    Thread Starter keithfarmer

    (@keithfarmer)

    Hi Mikko
    Many thanks for responding to this.
    It turned out that the normal theme default search was happily showing the highlighted excerpts, and responding as expected.

    The file it uses, search.php, doesn’t use the_excerpts(), but instead uses truncate_post( 270 ); but as I said it works fine with the default search.
    Link here https://pastebin.com/2vsk23j2

    I replaced truncate() with the_excerpts() and it worked just the same in the default search and from the Search & Filter Pro. ie it worked fine in the default search and not in the Search & Filter Pro search.

    So in Search & Filter Pro I set the display search results to use the same file as WordPress is using search.php, in my child theme folder to display results, but weirdly it doesn’t show the highlighted excerpts when called from the custom form.
    Development website here
    https://www.test.fresh-interactive.co.uk/publications/advanced-search/
    (The form is Search & Filter Pro, the default search is top right)

    I guess that the default search and the Search & Filter Pro are somehow calling the file differently or that parameters are different?

    The custom form calls search like this where brick is the search term
    https://www.test.fresh-interactive.co.uk/?sfid=736&_sf_s=brick

    Deafult search calls it like this
    https://www.test.fresh-interactive.co.uk/?s=brick

    Any ideas? Stuck here and it’s the core of the site!

    Many thanks

    Keith

    Plugin Author Mikko Saari

    (@msaari)

    What if you replace the_excerpt() in the template with relevanssi_the_excerpt()? Does that help?

    Thread Starter keithfarmer

    (@keithfarmer)

    Hi Mikko
    Thanks

    I tried this and the function produces no output in place of the truncate_post( 270 ); or the_excerpt()

    I appreciate your help on this and I’m happy to upgrade to your pro version if it will help?

    Best regards

    Keith

    Thread Starter keithfarmer

    (@keithfarmer)

    Further to the above: the genaric theme search produced results with the relevanssi_the_excerpt() code but not the custom form.

    Best regards

    Keith

    Plugin Author Mikko Saari

    (@msaari)

    Well, if you buy Premium, I can do some debugging on your site to figure out what’s wrong, but if the problem is in Search & Filter, there’s little I can do about it.

    add_filter('relevanssi_pre_excerpt_content', 'rlv_test_query', 10, 3);
    function rlv_test_query($content, $post, $query) {
        var_dump($query);
        exit();
    }

    If you add this code to the functions.php, what does it print out in the different searches?

    Thread Starter keithfarmer

    (@keithfarmer)

    Hi Mikko

    With theme search the printout is
    string(5) “brick”

    With the Search & Filter search it comes out as normal. No highlighting and no string count.

    Best regards

    Keith

    Plugin Author Mikko Saari

    (@msaari)

    In that case Search & Filter searches are simply not using Relevanssi at all to create the excerpts. I’d look into the search results template to see why that is so.

    Thread Starter keithfarmer

    (@keithfarmer)

    Hi Mikko

    I have feedback on this from Search & Filter Pro and the reason is that though they support some parts of Relevanssi they do not support excerpt snippets. Sorry to waste your time. I though Relevanssi support meant just that. oops. It is now raised onto the wish list. So hopefully it might happen some day.

    In the meantime, I am scratching my head as where to go now.

    Keith

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Plugin Relevanssi Highlighting search terms in results not working’ is closed to new replies.