Site logo

Archived topic

Woocommerce search in menu with WPML goes to default language

3 replies · Started by John MacKenzie on September 9, 2020

Viewing posts 1–4 of 4

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!

Hi Tom thanks!

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

John

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.

This archived topic is closed to new replies.