Doing a search using the navbar searchform overlay while on a translated version of the site switches back to the original language when returning the results. This is due to the search form missing a hidden input field for ‘lang’, as described in https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/search-form/.
I’ve fixed this temporarily using a PHP snippet based on https://theme.co/apex/forums/topic/append-search-url/ and https://wpml.org/wpml-hook/wpml_add_language_form_field/:
if ( ! function_exists( 'x_navbar_searchform_overlay' ) ) :
function x_navbar_searchform_overlay() {
if ( x_get_option( 'x_header_search_enable', '' ) == '1' ) :
?>
<div class="x-searchform-overlay">
<div class="x-searchform-overlay-inner">
<div class="x-container max width">
<form method="get" id="searchform" class="form-search center-text" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label for="s" class="cfc-h-tx tt-upper"><?php _e( 'Type and Press “enter” to Search', '__x__' ); ?></label>
<input type="text" id="s" class="search-query cfc-h-tx center-text tt-upper" name="s" />
<?php do_action( 'wpml_add_language_form_field' ) // adds hidden field for lang ?>
</form>
</div>
</div>
</div>
<?php
endif;
}
add_action( 'x_before_site_end', 'x_navbar_searchform_overlay' );
endif;