• Search widget is not shown with slug available in other languages. What can be the problem?

    Current structure:
    1- Elementor Pro
    2- hello elementor theme

    How it was tested:
    1- The default language is Turkish. It has been set.
    2- Default language, search archive page copied to English language. (/en/?s=test manual running)
    3- Default header, copied to English language.
    4- English header, click search widget, searched “test”.
    5- The search results resulted in the default language search “/?s=test” (should be: /en/?s=test)

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thank you @mawe .
    I tested this code on my website.
    it works very well

    Plugin Author Pacotole

    (@pacotole)

    You can try Polylang Connect for Elementor v2 Beta where this problem is also fixed.

    Sorry, just found the answer to my question…

    dilarasire

    (@dilarasire)

    Hello @mawe , how and where can I apply the code ? Thanks in advance! Please tell me

    Problem still exists today. If you use a generic theme you need to create your own “searchform.php” file and put it in the root of your template folder as a workaround.

    I am facing a similar problem, and I’m not using Elementor. When using the WP Search block, results switch to the default language.

    The team from GeneratePress kindly helped me find a workaround. I post their solution here in case somebody else needs it.

    They suggested creating a new search form shortcode adding this PHP snippet:

    add_shortcode( ‘search_form’, function() {
    ob_start();

    ?>
    <form role=”search” method=”get” class=”search-form” action=”<?php echo home_url() . ‘/’ . pll_current_language(); ?>”>
    <label>
    <span class=”screen-reader-text”><?php echo _x( ‘Search for:’, ‘label’ ) ?></span>
    <input type=”search” class=”search-field”
    placeholder=”<?php echo esc_attr_x( ‘Search …’, ‘placeholder’ ) ?>”
    value=”<?php echo get_search_query() ?>” name=”s”
    title=”<?php echo esc_attr_x( ‘Search for:’, ‘label’ ) ?>” />
    </label>
    <input type=”submit” class=”search-submit”
    value=”<?php echo esc_attr_x( ‘Search’, ‘submit button’ ) ?>” />
    </form>

    <?php

    return ob_get_clean();
    } );`

    Then you can insert this shortcode to generate a search widget: [search_form]

    It worked for me. I hope it helps you too. ??

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘The search results are redirected to the default language’ is closed to new replies.