• Resolved tamerkilinc

    (@tamerkilinc)


    Hey there!

    First I want to thank for such a great plugin.

    I noticed a small issue which depends on just one plugin, I think. My website / shop has two different languages and they are distinguished by a query var in the url. When you visit my site and change the language to English you can see that a new query var is added to the url which says no more than ,,lang=en”.

    When I try to search something on the English version of the site it always shows the search results on the German site (lang=en is removed). I think this is because relevanssi uses the site_url and appends the search query vars.

    How can I tell Relevanssi that it has to read which language is been set actually and consider this when building the url for the search (maybe with $_GET[“lang”]?). Where do I have to add some extra code to do this?

    Thank you for your time!

    The page I need help with: [log in to see the link]

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

    (@msaari)

    You can add the lang parameter to the search form:

    <input type="hidden" name="lang" value="<?php echo ICL_LANGUAGE_CODE; ?>" />

    That way you end up with a URL like https://example.com/?s=bag&post_type=product&lang=en, which works. The language parameter currently appears in the form action:

    <form role="search" method="get" class="woocommerce-product-search" action="https://example.com/?lang=en">

    but that doesn’t work, the parameter is just not passed through there.

    Relevanssi doesn’t use site_url; Relevanssi doesn’t build the URL at all, that’s all up to WordPress.

    Thread Starter tamerkilinc

    (@tamerkilinc)

    Thank you for your reply. I have customized the custom storefront / woocommerce search and now it works.

    For those who are inserting their form as string in a variable, you have to include the language parameter like this:

    $form = ' ..
               ..
         <input type="hidden" name="lang" value="' . (ICL_LANGUAGE_CODE) . '" />
              .. ';
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Searching in the actual language’ is closed to new replies.