Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 10:00 8:00 – 10:00 8:00 – 13:00 8:00 – 13:00 9:00 – 13:00 -
- 11:00 – 17:00 11:00 – 17:00 14:00 – 17:00 13:00 – 17:00 13:00 – 18:00 -

Supporter timezone: America/New_York (GMT-05:00)

Tagged: 

This topic contains 0 replies, has 0 voices.

Last updated by Lauren 1 day, 18 hours ago.

Assisted by: Lauren.

Author Posts
February 25, 2025 at 4:13 pm #16746915

desireeM

Background of the issue:
different domain per language
in wp-admin foo.fr/wp-admin default language is "fr" but current user has "wp-wpml_current_admin_language..." cookie with value "en"
when calling wp_get_upload_dir()['baseurl'] in wp-admin, the URL is the "en" (foo.com) domain instead of the current "fr" (foo.fr) domain

Symptoms:
The uploads URL in wp-admin is incorrect. I expected to see foo.fr/wp-content/uploads, but instead, I got foo.com/wp-content/uploads.

Questions:
Why is the uploads URL showing the 'en' domain instead of the 'fr' domain?
How can I ensure the uploads URL matches the current language domain?

February 25, 2025 at 6:57 pm #16747520

desireeM

I just realized that another issue I encountered recently https://wpml.org/forums/topic/wrong-url-on-translated-media-files-when-using-a-different-domain-per-language/#post-16747516 has the same root cause as this.

e.g. if I open foo.fr/wp-admin/post.php?post=1234&action=edit&lang=en then the uploads URL is foo.com instead of foo.fr

February 26, 2025 at 7:28 pm #16753178

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-05:00)

I have set up a test install with different domains per language and everything looks to be working correctly. Let me outline my tests here.

1. Log in to the English site at hidden link
2. Upload an image to the English library (URL shows like:
hidden link
3. Sync media to all languages and check the French library by changing the admin language switcher to French. URL still looks like:
hidden link
but the file path for the French copy of the image is:
hidden link

On the frontend of the site, switch to French. It keeps me logged in because I have the option to automatically log in and out set. I click the admin user bar to view the dashboard. Now, the backend looks like this:
hidden link
Uploads looks like:
hidden link
and the file path for the English image is:
hidden link

and for French is:
hidden link

So what I find is that changing the langauge using the admin language on the backend doesn't necessarily change the URL, but it is working as expected. Chagning the language on the frontend DOES change the URL and if you then access the backend, you will see the wp-admin with whichever language you visited last on the frontend.

If you would like to test my test site, let me know and I can share credentials and you can update your hosts file. If you are experiencing different results on your live site, please write out step by step what steps to take so I can confirm the steps. If the steps on your site are the same as mine with different results, then it could be a conflict with another plugin or theme and we will need to test minimal settings, which is best done in a staging site if you have one.