WPML
Trạng thái
Đã giải quyết

Tổng quan về lỗi

Đối với một số loại trường ACF, không thể nhân bản nội dung đúng cách.

Giải pháp tạm thời

Nếu bạn đang sử dụng bất kỳ trường nào được liệt kê trong phần Miêu tả đầy đủ của bài viết này, bạn nên thêm đoạn mã này vào tệp functions.php của giao diện để tính năng nhân bản hoạt động bình thường.

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 );

LƯU Ý: Bạn nên thay thế các cặp key => value của mảng bằng các giá trị thích hợp.

Thay thế các khóa như: ‘test_taxonomy’, ‘test_image’, ‘test_file’, v.v. bằng tên trường trên trang web của bạn, như được hiển thị trong ví dụ hình ảnh sau. hình ảnh 01
Thay thế các giá trị như: ‘some_taxonomy_name’, ‘attachment’, post, page, v.v. tương ứng.
Đây là loại phần tử mà ID thuộc về. Có thể là post, page, attachment, {custom post type key}, nav_menu, nav_menu_item, category, post_tag, {custom taxonomy key}

Để biết thêm thông tin, vui lòng xem tài liệu về hook của chúng tôi tại đây.

Tất cả các lỗi đã ghi nhận →