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
9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 5 replies, has 1 voice.

Last updated by Christopher Amirian 4 days, 11 hours ago.

Assisted by: Christopher Amirian.

Author Posts
January 31, 2025 at 3:35 pm #16656583

Hardik Sarodiya

Background of the issue:
I am working on a site under development with multiple pages using a fallback mechanism. For example, the page 'xyz.com/fr/product/abc' is available in 10 different languages and is currently viewed in French. This page contains several relative links, including one to '/fr/product/def'. However, the DEF page is only available in English, Traditional Chinese, and Korean.

Symptoms:
When setting the relative link '/fr/product/def' in the ABC page, the frontend browser automatically displays the '/zh-hans/product/def' language code instead of 'fr'.

Questions:
How can I prevent the relative path links from changing automatically for fallback pages?

February 1, 2025 at 11:11 am #16658215

Hardik Sarodiya

Hello,
We are waiting for the replay as this is the high priority issue for us.

February 3, 2025 at 9:45 am #16662009

Hardik Sarodiya

Hello
I need urgent assistance.

As shown in the attached screenshot, my page is in French, and I have set "/fr/url" as the fallback page. However, in the browser, it appears in a different language and redirects to the Traditional Chinese (zh-hant) page.

Could you please provide guidance on this issue?

wpml_sc.png
February 4, 2025 at 7:35 am #16665065

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Welcome to WPML support. It takes typically 1-2 working days for the replies. I appreciate your patience.

This seems to be very edge scenario which is using a relative link to a page that does not have the language at all.

If the French version is not available WPML will not have any way of predicting what to do.

The best way forward is as follows:

- Use an absolute URL in the original language.
- If for any reason you would later want to move the website you can do a simple search and replace using the search and replace plugin to change all instances of the domain to the other one you like.
- After you change the link to the absolute version make sure you complete the translation in the Advanced translation editor.
- IMPORTANT STEP! Create a backup of your website.
- Go to WP Dashboard > WPML > Settings and scroll down to Translate Link Targets
section.
- Click the scan button and wait for the process to finish.
- Now the French version should be populated automatically and you do not need to add anything in translation.
- Depending on the setting you set in WPML > Languages > Language switcher options it will fallback to the default language if there is no translation for French.

Thank you.

February 4, 2025 at 10:36 am #16666108

Hardik Sarodiya

As you mentioned, WPML won’t have any predictions, but is there a way for WPML to do nothing and keep the relative URL unchanged ?
Or
is there any action or hook available in which WPML identified that this link is not available in such case we can redirect it to default english language page via code.

Please provide your inputs with priority.

February 4, 2025 at 12:33 pm #16666667

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Unfortunately, it is not possible to consider a relative URL as a link as WPML can not understand the context and it might be confused with a normal text.

Whatever hooks I see are for absolute URLs. The one that is related to links is:

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-662194

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-605226

and

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-605256

Thanks.