• Resolved swbdatw

    (@swbdatw)


    I would like to integrate the search into a multilingual website with Polylang. There is the following problem:
    When I submit the search form, it automatically switches to the main language of the website.

    Of course, I would like it to stay in the desired language during the search.
    Is that possible?

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

    (@msaari)

    Ensure there’s a language parameter in the search form set to the current language. If there’s no language parameter, the site may switch the language to the default language.

    Thread Starter swbdatw

    (@swbdatw)

    OK, and how can I do that?

    We code the Site all manual…

    <form role="search" method="get" id="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="input-group my-2">
    <div class="input-group">
    <div class="input-group-prepend">
    <span class="input-group-text p-0">
    <i class="fas fa-search text-muted"></i>
    </span>
    </div>
    <div class="inline-block">
    <div class="thesearch">
    <input type="search" size="3" class="form-control border-0" placeholder="Search..." aria-label="search nico" name="s" id="search-input" value="<?php echo esc_attr( get_search_query() ); ?>">
    </div>
    </div>
    </div>
    </form>
    Plugin Author Mikko Saari

    (@msaari)

    Add a hidden input field in the search form with the name lang and the value set to the current language. I’m sure Polylang has a function to print out the current language code.

    Thread Starter swbdatw

    (@swbdatw)

    It worked. Thank you very much! :)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Switching to main language using Polylang’ is closed to new replies.