Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

This topic contains 2 replies, has 0 voices.

Last updated by Ayelet Oz 18 minutes ago.

Assisted by: Bruno Kos.

Author Posts
February 25, 2025 at 9:03 am #16744505

Ayelet Oz

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?

February 25, 2025 at 9:20 am #16744564

Bruno Kos
Supporter

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.

February 25, 2025 at 9:09 pm #16748111

Ayelet Oz

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....