WPML

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

This issue is fixed in JetSearch 3.2.0. Updating solves it on your site, so you only need this workaround if you can’t update yet.

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'] );
    }

Still Seeing This Issue?

If updating doesn’t fix it, ask a support question and we’ll look into it with you.

Ask a support question

All known issues