- 状态
- 未解决
- 相关插件/主题
- Advanced Custom Fields
- 主题标签
- Compatibility
问题概述
当将ACF – Advanced Custom Fields与ACFML 插件一起使用时,如果将 Clone 字段设置为复制一次,则无法在前端以原始语言获取字段值。当包含 Clone 字段的字段组被设置为跨语言的不同字段,或者在专家模式下手动将该字段设置为复制一次时,会出现此问题。
临时解决方法
请在继续操作之前,确保已对您的网站进行完整的站点备份。
- 打开 …wp-content/plugins/acfml/classes/class-wpml-acf-custom-fields-sync.php 文件。
- 找到第 42 行。
- 将:
public function clean_empty_values_for_copy_once_field( $value, $post_id, $field ) { if ( '' === $value && ! $this->value_has_been_emptied( $field ) && isset( $field['wpml_cf_preferences'] ) && WPML_COPY_ONCE_CUSTOM_FIELD === $field['wpml_cf_preferences'] && ! $this->isFieldType( $field, 'group' ) ) { $value = null; } return $value; } - 替换为:
// WPML Workaround for compsupp-7767 public function clean_empty_values_for_copy_once_field( $value, $post_id, $field ) { if ( '' === $value && ! $this->value_has_been_emptied( $field ) && isset( $field['wpml_cf_preferences'] ) && WPML_COPY_ONCE_CUSTOM_FIELD === $field['wpml_cf_preferences'] && ! $this->isFieldType( $field, 'group' ) && ! $this->isFieldType( $field, 'clone' ) ) { $value = null; } return $value; }