Resolved by author
Resolved in: JetSearch 3.2.0
Overview of the issue
When using WPML and JetSearch plugin together, the search result preview area only displays posts in the default language, even when the user switches to a different language and searches for a post in that language.
Workaround
Please, make sure of having a full backup of your site before proceeding.
- First, open …/wp-content/plugins/jet-search/includes/ajax-handlers.php file.
- Look for line 61.
- Just below add:
//WPML workaround for compsupp-6886 - Part I if ( isset( $_GET[ 'wpml_lang' ] ) ) { do_action( 'wpml_switch_language', $_GET[ 'wpml_lang' ] ); // switch the content language }
- Second, open …/wp-content/plugins/jet-search/includes/assets.php file:
- Look for line 151.
- Just below this line:
$this->localize_data['rest_api_url'] = get_site_url() . "/wp-json/jet-search/v1/search-posts";
- Add:
//WPML workaround for compsupp-6886 - Part II $wpml_current_lang = apply_filters( 'wpml_current_language', NULL ); if ( $wpml_current_lang ) { $this->localize_data['rest_api_url'] = add_query_arg( 'wpml_lang', $wpml_current_lang, $this->localize_data['rest_api_url'] ); }