WPML
状态
未解决
相关插件/主题
Filter Everything PRO
主题标签
Compatibility

问题概述

结合使用 Filter Everything 插件与 Advanced Custom Fields 的用户可能会遇到一个问题:在筛选器中使用的 ACF 字段值在前端未被翻译。尽管这些字段已在 WPML 字符串翻译中进行了翻译,此问题依然存在。

临时解决方法

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


  • 将以下代码添加到主题的 functions.php 文件中:
    // WPML Workaround for compsupp-7581
    add_filter('wpc_terms_before_display', 'wpml_compsupp7581_filter_wpc_filter_terms', 10, 4 ); 
    
    function wpml_compsupp7581_filter_wpc_filter_terms($terms, $filter, $set, $urlManager) {
    	
    	if ( class_exists('Sitepress') ) {
    		foreach ($terms as &$term ) {
    			$label = $term->name;
    			$textdomain = 'WordPress';
    			$string_name = 'WPC Filter Label: '.substr($label, 0, 40);
    
    			if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
    				do_action( 'wpml_register_single_string', $textdomain, $string_name, $label );
    			}	
    			// Apply the translation to the string
    			$term->name = apply_filters('wpml_translate_single_string', $label , $textdomain, $string_name);
    
    		}
    	}
    	return $terms;
    }

  • 使用原始语言访问出现问题的页面。此操作将注册该字符串。

  • 前往 WPML > 字符串翻译页面并翻译该字符串。它应该位于 WordPress textdomain 下。

所有已知问题 →