WPML
상태
해결됨

문제 개요

일부 ACF 필드 유형의 경우 콘텐츠를 제대로 복제할 수 없습니다.

임시 해결 방법

이 글의 전체 설명 섹션에 나열된 필드를 사용하는 경우, 복제가 제대로 작동하도록 테마의 functions.php 파일에 이 스니펫을 추가하세요.

function wpml_fix_acf_duplication( $value_to_filter, $target_language, $meta_data ) {
  // Field names should be placed into following array.
  $fields = array(
     'test_taxonomy' => 'some_taxonomy_name',
     'test_image' => 'attachment',
     'test_file' => 'attachment',
     'test_gallery' => 'attachment',
     'test_post_object' => 'post',
     'test_page_link' => 'page'
  );

  if ( array_key_exists( $meta_data['key'], $fields ) ) {
		$value = maybe_unserialize( $value_to_filter );

		if ( is_array( $value ) ) {
			// If custom field value contain array of IDs to translate, usually used for gallery and taxonomy field types.
			$translated_ids = array();

			foreach ( $value as $v ) {
				$translated_ids[] = apply_filters( 'wpml_object_id', $v, $fields[ $meta_data['key'] ], true, $target_language );
			}

			return maybe_serialize( $translated_ids );
		} else {
			// If custom field value contain single ID to translate, usually used for image and file field types.
			$translated_id = apply_filters( 'wpml_object_id', $value, $fields[ $meta_data['key'] ], true, $target_language );

			return $translated_id;
		}
	}

	return $value_to_filter;
}
add_filter( 'wpml_duplicate_generic_string', 'wpml_fix_acf_duplication', 999, 3 );

참고: 배열의 key => value 쌍을 적절한 값으로 교체하세요.

다음 이미지 예시와 같이 ‘test_taxonomy’, ‘test_image’, ‘test_file’ 등의 를 사이트의 필드 이름으로 교체하세요. image01
이에 맞게 ‘some_taxonomy_name’, ‘attachment’, post, page 등의 을 교체하세요.
이는 ID가 속한 요소의 유형입니다. post, page, attachment, {custom post type key}, nav_menu, nav_menu_item, category, post_tag, {custom taxonomy key}를 사용할 수 있습니다.

자세한 내용은 여기에서 훅 문서를 확인하세요.

알려진 모든 문제 →