Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are experiencing issues with translated posts not being found due to complex permalink structures and custom rewrite rules in a multilingual WordPress setup using WPML.
Solution:
We recommend modifying the timing of your redirect rules. Instead of loading your redirects on 'init', try using the 'wpml-loaded' action. This ensures that WPML's language handling is fully loaded before your custom rewrite rules are applied, which helps in maintaining the correct language directories in URLs. For more details on this hook, please visit https://wpml.org/wpml-hook/wpml_loaded/.

If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.

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.

Our next available supporter will start replying to tickets in about 1.55 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by Andreas W. 1 month, 2 weeks ago.

Assisted by: Andreas W..

Author Posts
September 27, 2024 at 5:24 pm #16230962

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

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

Please take kindly note, that we ony handle one issue per ticket. In case you need further assistance I can offer to split new topics into new tickets and then we can follow up from there.

About your first example:

The translated post is here:
hidden link

Issues:

1) The language switcher in the header of your site is not working, as it is not an official WPML language switcher.

Guide:
https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/

2) When translating the CPT slug please do not include the language direcotry. See screenshot.

language directory.jpg
September 30, 2024 at 9:49 am #16235281

davidH-179

Thanks, we do use the standard wpml language switcher.

It works on some pages, but not others... So I don't think this is the issue?

I think the issue is because we use custom taxonomies (code that I pasted to you earlier).

Screenshot 2024-09-30 at 10.48.30.png
Screenshot 2024-09-30 at 10.48.22.png
September 30, 2024 at 1:12 pm #16236376

davidH-179

For example, a single visa page. If you try to use the language switcher to access the chinese page, the url is missing the 'zh-hans' part.

If you navigate the site in Chinese, you can find the page....

hidden link

October 1, 2024 at 1:00 am #16238015

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

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

Your site is using:

Different languages in directories
hidden link - English, hidden link - Chinese (Simplified)

The language directories use the language code by default.

Example:
hidden link - English
hidden link - Chinese

The translated post for this content can not be found because for some reason your redirect rules remove the language directory from the language switcher:

Original:
hidden link

Redirect:
hidden link

Translation:
hidden link

Possible solution:
Please try to load your redirects not on init, and instead use 'wpml-loaded':
https://wpml.org/wpml-hook/wpml_loaded/