I'm in the midst of a theme conversion and migration: from an Woocommerce with Polylang Pro to a non-Woocommerce with WPML theme.
After the initial Polylang-to-WPML procedure using your tool (hidden link) and following your how-to guide (https://wpml.org/documentation/related-projects/migrate-polylang-wpml/), I realised that the client had many (if not all) product posts featuring the right/translated title, but the slugs that are the same of the base lang post title. E.g.:
Title it: "Prodotto 1"
Slug it: "prodotto-1"
Title en: "Product 1"
Slug en: "prodotto-1"
Title fr: "Produit 1"
Slug fr: "prodotto-1"
As you can see, the titles are correctly translated but not the slugs. Maybe because the client copied the original post, and forgot to change the slug. I don't know...
So what I did is to run once the following php snippet directly from the functions.php, in order to update all the slugs at once:
foreach ($posts as $post) {
$new_slug = sanitize_title($post->post_title);
wp_update_post(
array(
'post_name' => $new_slug
)
);
}
However looks like it doesn't work, meaning that if I dump&die the $posts object, I still get the "post_name" NOT updated. Maybe I've missed something...
Thank you for contacting WPML support, I'd be happy to help you with this issue.
You are using a custom code to update the post slug on your site, I would like to inform you that helping you with custom code, is out of the scope of WPML. But I have a suggestion:
If you are not able to accomplish this, I would recommend you contact one of our certified partners who will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/