[Support request] Woocommerce search in menu with WPML goes to default language

Home Forums Support Woocommerce search in menu with WPML goes to default language

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1436828
    John MacKenzie

    hi guys i found this article on wpml and tried this (in child theme override)
    https://wpml.org/forums/topic/problem-with-the-search-wrong-language-in-the-results/
    but it didnt do anything.
    when searching in english in the menu search, it defaults back to french.

    how can we solve this?

    Thanks!

    #1437281
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You should do something like this, instead:

    add_filter( 'generate_navigation_search_output', function() {
        return sprintf( // WPCS: XSS ok, sanitization ok.
            '<form method="get" class="search-form navigation-search" action="%1$s">
                <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
                <input type="hidden" name="lang" value="%4$s" />
            </form>',
            esc_url( home_url( '/' ) ),
            esc_attr( get_search_query() ),
            esc_attr_x( 'Search', 'label', 'generatepress' ),
            apply_filters( 'wpml_current_language', NULL )
        );
    } );

    It should be added to your functions.php file.

    Hope this helps!

    #1437364
    John MacKenzie

    Hi Tom thanks!

    i added that but it didnt appear to make any difference?

    John

    #1438308
    Tom
    Lead Developer
    Lead Developer

    That code is simply a better method of what WPML suggested. I’m afraid I’m not aware of the inner-working of their code, so I’m not sure if it will actually fix the issue. It may be worth getting in touch with their support to see if something has changed.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.