Created
March 18, 2022 08:16
-
-
Save moritzbappert/793f22810cf4c41cc44ce3debbab4b4b to your computer and use it in GitHub Desktop.
WPML: copy / duplicate product url slugs from original language to other languages #woocommerce #wpml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE | |
wp_posts posts | |
INNER JOIN ( | |
SELECT | |
original_id.id, | |
p_original_slug.post_name | |
FROM ( | |
SELECT | |
p.id, | |
tr.language_code, | |
tra.element_id AS original_id | |
FROM | |
wp_posts p | |
INNER JOIN wp_icl_translations tr ON tr.element_id = p.id | |
LEFT JOIN wp_icl_translations tra ON (tra.trid = tr.trid AND tra.language_code = 'en') | |
WHERE | |
tr.element_type = 'post_product' | |
) original_id | |
LEFT JOIN wp_posts p_original_slug ON original_id.original_id = p_original_slug.id | |
WHERE (original_id.language_code = 'fr' OR original_id.language_code = 'de') | |
) lookup_table ON posts.id = lookup_table.id | |
SET posts.post_name = lookup_table.post_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this to reset product urls that had already been translated by WPML from
en
tode
andfr
to the original product url slug from the source languageen
.