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