Navigation überspringen
Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 7:00 – 12:00 -
- 13:00 – 15:00 13:00 – 15:00 13:00 – 15:00 13:00 – 15:00 13:00 – 15:00 -

Unterstützt die Zeitzone: Europe/Madrid (GMT+02:00)

Dieses Thema enthält 0 Antworten, hat 1 Stimme.

Zuletzt aktualisiert von danielM-79 Vor 3 Monate, 1 Woche.

Assistiert von: Carlos Rojas.

Verfasser Beiträge
Juni 14, 2024 unter 11:16 am #15739822

danielM-79

Background of the issue:
We have a dual language (English [default lang], Turkish) education related website. It has 2 custom post types: courses and institutes (university). Each course is linked to a university via a meta field (course_institute) that stores the ID of the institute, either the English or the Turkish post ID, depending on the translation of the course. We use this code to find and store the Turkish ID of the institute, whenever a Turkish translation of a course is created or updated. However, often this code is not executed.

add_action('wpml_pro_translation_completed', function($post_id, $fields, $job) {
$lang = apply_filters( 'wpml_post_language_details', '', $post_id );
$lang = isset($lang['language_code']) ? $lang['language_code'] : '';

$default_language = apply_filters( 'wpml_default_language', NULL );
$original_course_id = apply_filters( 'wpml_object_id', $post_id, 'post', true, $default_language );

$original_institute_id = get_post_meta($original_course_id, 'course_institute', true);
$translated_institute_id = apply_filters( 'wpml_object_id', $original_institute_id, 'university', false, $lang );

update_post_meta($post_id, 'course_institute', $translated_institute_id);
}, 10, 3);

Symptoms:
The code to find and store the Turkish ID of the institute is often not executed.

Questions:
Which is the recommended hook or solution to guarantee that the action is executed when a translation is updated or finished?
Is there any documentation that you are following?

Das Thema '[Geschlossen] Translating post ID stored as meta field' ist für neue Antworten geschlossen.