Created
June 11, 2015 07:39
-
-
Save hampusn/21d316d36d38bae8c336 to your computer and use it in GitHub Desktop.
SQL queries to detach WPML duplicates and translate them separately.
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
# Select all posts which are duplicates of a language. | |
# The language parameter is to only select by the new language (not the original duplication language). | |
SET @lang_code = 'da'; | |
SELECT pm.*, p.post_title, p.post_type, icl.language_code | |
FROM wp_postmeta pm | |
INNER JOIN wp_icl_translations icl ON icl.element_id = pm.post_id | |
INNER JOIN wp_posts p ON p.`ID` = pm.post_id | |
WHERE meta_key='_icl_lang_duplicate_of' AND icl.language_code = @lang_code; | |
# Same as above but to delete instead of select. The above should be used first to | |
# make sure that you don't delete the wrong rows ;) | |
SET @lang_code = 'da'; | |
DELETE pm | |
FROM wp_postmeta pm | |
INNER JOIN wp_icl_translations icl ON icl.element_id = pm.post_id | |
WHERE meta_key='_icl_lang_duplicate_of' AND icl.language_code = @lang_code; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment