about the second issue - I've already tried that, and now tried again. The post_name updates, but the permalink, the url of the product, stays the same, and not getting the english one. I also tried adding flush_rewrite_rules();, but it didn't help.
any ideas?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+01:00)
I’ve created a new ticket for this issue:
hidden link
Can you test it using the following code?
function custom_wpml_set_duplicate_permalink($post_id) {
// Ensure we're not in an autosave routine
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// Check if this is a WPML duplicate
$is_duplicate = get_post_meta($post_id, '_wpml_duplicate', true);
if (!$is_duplicate) {
return;
}
// Get the original post ID
$original_post_id = apply_filters('wpml_object_id', $post_id, get_post_type($post_id), false, wpml_get_default_language());
if (!$original_post_id) {
return;
}
// Get the original post's slug
$original_post = get_post($original_post_id);
$original_slug = $original_post->post_name;
if ($original_slug) {
// Update the duplicated post's slug to match the original
remove_action('save_post', 'custom_wpml_set_duplicate_permalink'); // Prevent infinite loop
wp_update_post([
'ID' => $post_id,
'post_name' => $original_slug
]);
add_action('save_post', 'custom_wpml_set_duplicate_permalink'); // Re-add after update
}
}
add_action('save_post', 'custom_wpml_set_duplicate_permalink');
Can you try reproducing this issue in the sandbox?
Based on your tests, do you mean that while the `post_name` (slug) updates correctly, the permalink (full URL) does not reflect the English version?
If that’s the case, could you record the process using a tool like **hidden link to show where it fails? This would help me better understand the difference between the slug and the full URL in this scenario.
You asked - Based on your tests, do you mean that while the `post_name` (slug) updates correctly, the permalink (full URL) does not reflect the English version? Yes, exactly.
I couldn't record....