Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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.

This topic contains 23 replies, has 4 voices.

Last updated by sarah.n 6 years, 1 month ago.

Assigned support staff: sarah.n.

Author Posts
December 11, 2013 at 8:48 am #306028

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Eric,

As promised here is how you will delete your attachment duplicates. There are 3 separate queries that you will have to run one after the other and in the order given. The order is important!

You will run each as an SQL Command directly in phpMyAdmin but please, please make sure you have made a full database backup before you attempt this!

1.

DELETE FROM wp_posts WHERE
ID IN
(
 SELECT element_id FROM wp_icl_translations WHERE element_type = 'post_attachment' AND language_code != 'en'
)

2.

DELETE FROM wp_postmeta WHERE
meta_key= '_thumbnail_id' AND meta_value IN 
(
SELECT element_id FROM wp_icl_translations WHERE element_type = 'post_attachment' AND language_code != 'en'
)

3.

DELETE  FROM wp_icl_translations WHERE element_type = 'post_attachment' AND language_code != 'en';

Like mentioned above. Do NOT run the above sqlsbefore you have made a full database backup!

December 11, 2013 at 5:20 pm #306888

OlivierL

Hi Sarah

I will try that but to be able to do so, my website needs to be fixed up.
Could you please have a look with Bruno of what he is doing because I contacted him after losing the language switcher again and now my whole client homepage is messed up and I'm leaving for 3 days tomorrow evening. I can't have the website down for the week-end. We will lose leads because it's our busiest time.

Thanks by advance,
Olivier

December 12, 2013 at 9:02 am #307182

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Eric,

It seems you are referring to a different ticket. Could it be this: http://wpml.org/forums/topic/language-switcher-disappeared-of-header/#post-307078 ?

I'll reply there so as to not mix the 2 issues.

December 17, 2013 at 9:47 am #309417

OlivierL

Hi Sarah

I have tried to run your first SQL Command and I get this error message:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''post_attachment' AND language_code != 'en' )' at line 4

December 17, 2013 at 10:15 am #309445

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Do you also get the error when you simply run:

SELECT element_id FROM wp_icl_translations WHERE element_type = 'post_attachment' AND language_code != 'en'
December 17, 2013 at 10:33 am #309469

OlivierL

Yes sarah

December 17, 2013 at 12:27 pm #309582

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Well this is weird because when I run it it works. I am using your db - please see attached screenshot.

December 17, 2013 at 12:54 pm #309612

OlivierL

which database do you use, sarah? is it eliplay-wrdp3?
I assume it was that one because it has the most data in.
I'm really newbie with SQL server and phpAdmin
so what I did is :
1 - I go into phpMyAdmin
2- I selected eliplay-wrdp3 as database on the left
3- I clicked on SQL and entered the code you gave me in the box (Run SQL queries)
and that's when I got that message

December 17, 2013 at 1:23 pm #309642

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Yes it was "eliplay_wrdp3" this is the one that the WordPress installation to which access was provided is using.

OK let's try this. I took the liberty and installed a plugin called "Adminer" in your WordPress installation. I would normally have first asked for your permission to do this however I thought this will save us the extra time.

1. Go to: /wp-admin/tools.php?page=adminer/adminer.php and click on "Start Adminer in a new tab" - see screenshot

2. Then click on "SQL Commend" (top left) - see screenshot

3. Finally enter the SELECT SQL in the provided area and click on "execute" - see screenshot

Ensure that you have the expected results - at least the number.

Double check you have the recent database copy available and then run the DELETE commands in the order given previously.

Hope this helps 🙂

The topic ‘[Closed] How to delete in one go all photos duplicates in various languages’ is closed to new replies.