This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Recent updates change search results behaviour for bi-lingual sites?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Recent updates change search results behaviour for bi-lingual sites? Reply To: Recent updates change search results behaviour for bi-lingual sites?

#31588
Ernest MarcinkoErnest Marcinko
Keymaster

I just re-read your post, but I may have missunderstood you.

I noticed that WPML compatibility is OFF, which means that results are returned regardless of the language regardless of which language is opened.
So if I go the BG version of the site, then type in “larry” I get the english results, which lead me to the english version of the product – which is the correct behavior.
When WPML compatibility is turned OFF, the plugin returns any results for any languages. WPML may actually resolved the issue with ther hook, and now it works correctly, but in your case it is the “incorrect” way – because you want to redirect to a URL where the product actually does not exist.

I believe this might be still resolveable with a custom code though to replace the language string with the currently opened:

add_filter( 'asp_results', 'asp_change_lang_to_local', 10, 1 );
function asp_change_lang_to_local( $results ) {
	
	// Parse through each result item
	if ( defined('ICL_LANGUAGE_CODE') ) {
		foreach ($results as $k=>&$r) {
			if ( isset($r->post_type) ) {
				$r->link = apply_filters('wpml_permalink', $r->link, ICL_LANGUAGE_CODE, true);
				if ( strpos($r->link, ICL_LANGUAGE_CODE . '/') === false ) {
					$r->link = apply_filters('wpml_permalink', $r->link, ICL_LANGUAGE_CODE);
				}
			}
		}
	}

	return $results;
}

Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case! I have not been able to test this, so please be careful.