• 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 15 replies - 1 through 15 (of 21 total)
  • Plugin Author David Decker

    (@daveshine)

    @ayhanrv
    Hi and thanks for your feedback!
    The Elementor Pro Search widget currently does not respect various languages coming from multingual plugins like Polylang.

    However, Elementor Pro v2.7.0 brought new action hooks into the search widget, this could open the possibility for workarounds which we are currently considering/ trying to test. I cannot promise anything yet, but I hope that we can have a solution for this somehow.

    Search results per language in WordPress is already very difficult, even without Elementor already.

    If someone has other ideas or suggestions how to tackle this issue – all is very welcome!

    Thanks, Dave ??

    Thread Starter ayhanrv

    (@ayhanrv)

    @daveshine

    Hello, thank you for your support.

    I have a suggestion. We can solve this problem with the request parameter.
    I can reach the results by performing a manual test.

    Step by step:
    1- I am on the site translated into English.
    2- In the search box, I typed the search term “hello”.
    3- I clicked the Search button.
    4- The default language is Turkish. url: “/?s=hello”
    5- On the search results page, I changed the url manually, /en/?s=hello

    On a page copied from an English translated site, the search widget must have the url parameter / en.

    did this give you any idea?

    thank you.

    not:The wordpress search widget is the current url (for example: https://ayhanmalkoc.com/ or https://ayhanmalkoc.com/en or https://en.ayhanmalkoc.com/) “?s=hello” slug correctly he adds.

    • This reply was modified 5 years, 1 month ago by ayhanrv.
    • This reply was modified 5 years, 1 month ago by ayhanrv.
    Thread Starter ayhanrv

    (@ayhanrv)

    edit:

    @daveshine
    I have reviewed Elementor Pro “search-form.php”. I think the problem is that the home URL is set.

    <form class="elementor-search-form" role="search" action="<?php echo home_url(); ?>" method="get">

    devzstack

    (@devzstack)

    @ayhanrv
    hello.
    I have the same problem as you.

    <form class="elementor-search-form" role="search" 
    action="<?php echo home_url(); ?>" method="get">

    I think it should show the current language (i used plugin polylang)
    You can try replace code within the search-form.php

    search-form.php

    <form class="elementor-search-form" role="search" action="<?php echo home_url(); ?>/<?php echo pll_current_language(); ?>/" method="get">

    I hope it will help solve your problem.
    Thanks.

    • This reply was modified 5 years ago by devzstack.
    • This reply was modified 5 years ago by devzstack.
    • This reply was modified 5 years ago by devzstack.
    • This reply was modified 5 years ago by devzstack.
    Plugin Author Brad Johnson

    (@p4fbradjohnson)

    @devzstack

    Thanks for this information.

    Is this working 100%?

    If so, I will double-check it and see if we can get it implemented into the plugin.

    devzstack

    (@devzstack)

    @p4fbradjohnson

    hello, Yes it worked for me.
    You can try to test it at this link. https://tbj.devzstack.com/th/

    Thanks.

    Hi @p4fbradjohnson
    I have the same issue but the code you gave is unfortunately not working on my website ??
    It crashes it.
    Do you have by any chance another solution ?

    Thank you for your help

    Plugin Author Brad Johnson

    (@p4fbradjohnson)

    Unfortunately, this is still a work in progress

    Thank you for your answer ??

    Hello, I seem to be facing the same issue as many others.
    The default language is English but when I enter a search query in the search field on the secondary language (French-Fr) pages, I’ll be redirected to the English search results. How do I allow my results to appear for the correct language? I don’t know what is responsible for this redirect but I am sure there is a simple solution.

    thanks,

    Hello I had the same problem. I solved it by using javascript:

    1) I installed plugin “Insert Headers and Footers” (or other similar plugin that let you add javascript into footer of your sites)

    2) I added script to footer
    <script>
    jQuery( function( $ ) {
    $(‘.elementor-search-form’).submit(function (event) {
    if(document.querySelector(‘.some-class’) !== null) {
    $(‘.elementor-search-form’).prop(‘action’, ‘//www.somesite.com/langcode/’);
    }
    });
    } );
    </script>

    3) I added class to specific search form (in my case into header_en template) elementor console —> Edit search form —> Advanced —> CSS classes

    Hope this help someone…

    @p4fbradjohnson
    Have you been able to find a solution so that the search remains on the language used and does not switch to the default language?

    Have you been able to find a solution so that the search remains on the language used and does not switch to the default language?

    I tried a lot of technique but I always end up with search results in the default language and especially the header and the footer of this same language. I would like the results and the header to be in the language used before the search.

    Please Help !!

    Hello,

    I modified a little bit the code from @devzstack and it works for me (i use polylang too)
    My default langage is French.

    
     <form class="elementor-search-form" role="search" action="<?php echo home_url(); ?><?php if (pll_current_language() != 'fr') echo "/".pll_current_language(); ?> "
     method="get">
    
    • This reply was modified 3 years, 10 months ago by Sérey.

    For anyone still looking for this, here’s update-proof code to get the correct search url in the search form:

    add_action('elementor/widget/render_content', function($content, $widget) {
        if ($widget->get_name() == 'search-form' && function_exists('PLL')) {
            $dom = new DomDocument;
            $dom->loadHTML($content);
            $nodes = $dom->getElementsByTagName('form');
            $node = $nodes[0];
            $node->setAttribute('action', PLL()->curlang->search_url);
            $content = $dom->saveHTML($node);
        }
        
        return $content;
     }, 10, 2);

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

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