This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to ensure that when you edit the status of the original Dutch post on your site, the translated English page automatically reflects the same status (Published, Draft, Private). However, the translated English page does not automatically update to have the same status as the original Dutch post.
Solution:
We recommend using a code snippet to synchronize the status across different language versions of your posts. You should add the following code to the
functions.php
file of your theme:
function sync_publish_status_across_languages($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; if ('post' != get_post_type($post_id)) return; $post_status = get_post_status($post_id); $default_language = apply_filters('wpml_default_language', null); $translations = apply_filters('wpml_get_element_translations', null, $post_id, 'post'); foreach ($translations as $lang => $translation) { if ($lang === $default_language) continue; $translation_post_id = $translation->element_id; wp_update_post(array( 'ID' => $translation_post_id, 'post_status' => $post_status )); } } add_action('save_post', 'sync_publish_status_across_languages');
Please note, this solution applies only to pages and posts. Ensure you have a full website backup before implementing this code.
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket at WPML support forum for further assistance.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 1 reply, has 0 voices.
Last updated by 1 week, 3 days ago.
Assisted by: Lucas Vidal de Andrade.