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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 4 replies, has 2 voices.

Last updated by Mateus Getulio 4 months ago.

Assisted by: Mateus Getulio.

Author Posts
September 10, 2024 at 4:18 pm #16162799

ahmadS-21

If possible we would like to test the possibility of keeping the urls in their original form and not have them translated

September 10, 2024 at 4:27 pm #16162877

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

In order to accomplish it I took a few steps:

- Go to WPML > Languages > Edit languages
- Make sure Arabic uses encoded URLs
- Go to WPML > Settings > Translated documents options > Page URL
- Select 'Copy from original language if translation language uses encoded URLs' and save it

Now, the already translated pages, posts and products won't update right away, you need to make a minor edit to the original language post/product and save it so WPML sees the translation needs update. You can simply add an empty space anywhere in the post/page and save it, or do the change in bulk making a quick edit in the posts/products/pages listing screen.

After that, please check if the URL is already updated, if not, it might be necessary for you to edit the translation using the WPML advanced translation editor and save it.

I tested it for two products, only by making a small change(an extra empty space) to the main language product and saving it already applied the change to the secondary language, please check:

hidden link
hidden link

Can you please review it and let me know if this is what you're looking to achieve?

Thank you,
Mateus

September 11, 2024 at 8:43 am #16165178

ahmadS-21

hidden link I tries with this product but its not working

September 11, 2024 at 10:14 am #16165807

ahmadS-21

Ps:is there a way to do this for all the links at once not just product links?

September 11, 2024 at 5:56 pm #16167807

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

I checked the product you shared and it looks like the URL is working properly

I went ahead and performed the steps for this other product as well: hidden link

I recorded a quick video demonstrating it:

hidden link

I'm afraid there's no built-in way to perform it in bulk for all posts, products, pages and other CPTs.

What you could try was to make a full backup of the site, especially the database and try to programmatically force an update of the posts with a code like this:

function force_wpml_url_update() {
    // Get all posts, pages, and products
    $post_types = array('post', 'page', 'product');
    $args = array(
        'post_type' => $post_types,
        'post_status' => 'publish',
        'posts_per_page' => -1,
    );

    $all_posts = get_posts($args);

    foreach ($all_posts as $post) {
        // Make a minor change to the content to force URL update
        $post->post_content .= ' ';
        wp_update_post($post);
    }
}
add_action('admin_init', 'force_wpml_url_update');

The piece of code above will loop through your post, products and pages adding an empty space to the content and saving, the very same thing I performed in the video.

It is not guaranteed it would work, but in theory it should have the same effect. But it is extremely important that you have a backup in place first. After adding the code to the theme's functions.php file for example, you can open the wp-admin once and remove the code, it should be enough for it to run.

The topic ‘[Closed] Split: Use same URL/slug for translated items’ is closed to new replies.