- 状态
- 等待作者
- 相关插件/主题
- FacetWP
- 主题标签
- Compatibility
问题概述
如果您正在使用 FacetWP 插件,您可能会遇到这样的问题:使用 ACF 创建并在 FacetWP 分面中使用的复选框字段标签,在使用 Elementor 简码插入到页面时,无法显示其翻译。
临时解决方法
在继续操作之前,请确保对您的站点进行完整备份。
- 打开您主题的 functions.php 文件。
- 添加以下代码:
Add the following code to the functions.php file // WPML Workaround for compsupp-6751 function wpml_compsupp6751_translate_facet_display_value( $label, $args ) { if ( class_exists('Sitepress') ) { $wpml_default_lang = apply_filters('wpml_default_language', NULL ); $wpml_current_lang = apply_filters( 'wpml_current_language', NULL ); if ($wpml_default_lang == $wpml_current_lang ) { do_action( 'wpml_register_single_string', 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10), $label ); } // Apply the translation to the string $label = apply_filters('wpml_translate_single_string', $label , 'FacetWP', 'Facet Display Value : '.substr($label, 0, 10) ); } return $label; } add_filter( 'facetwp_facet_display_value', 'wpml_compsupp6751_translate_facet_display_value', 10, 2 ); - 访问前端的原始语言页面以注册字符串
- 前往 WPML > 字符串翻译 并翻译字符串(FacetWP textdomain / Facet Display Value : * name)