WPML
状态
已由作者解决
解决于
JetSearch 3.2.0
相关插件/主题
JetSearch
主题标签
Compatibility

问题概述

当同时使用 WPMLJetSearch 插件时,搜索结果预览区域仅显示默认语言的文章,即使当用户切换到其他语言并搜索该语言的文章时也是如此。

临时解决方法

在继续操作之前,请确保已对您的站点进行完整备份


  • 首先,打开 …/wp-content/plugins/jet-search/includes/ajax-handlers.php 文件。

  • 找到第 61 行。

  • 在正下方添加:
    			//WPML workaround for compsupp-6886 - Part I
    			if ( isset( $_GET[ 'wpml_lang' ] ) ) {
    				do_action( 'wpml_switch_language',  $_GET[ 'wpml_lang' ] ); // switch the content language
    			}

  • 其次,打开 …/wp-content/plugins/jet-search/includes/assets.php 文件:

  • 找到第 151 行。

  • 在此行正下方:
    				$this->localize_data['rest_api_url']  = get_site_url() . "/wp-json/jet-search/v1/search-posts";
  • 添加:
    				//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'] );
    				}	

所有已知问题 →