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}

למידע נוסף, עיין בתיעוד ההוקים שלנו כאן.

כל התקלות הידועות →