Skip Navigation

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

Problem:
You are developing a site and want to change the language URL format to include country codes like /ca/fr/ and /us/en/ instead of the default format like /fr-ca/ and /en-us/. You tried modifying the

REQUEST_URI

in an init hook but were unable to modify the permalink to achieve the desired URL format.
Solution:
Currently, we do not support the specific configuration you are asking for to include country codes in the language URL format. We are continuously working to enhance our features, and if we introduce more options for the URL format in the future, we will announce it through a blog post on our site. You can check for updates and related information on our blog.

If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. We also 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. For further assistance, please visit our 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.

Tagged: 

This topic contains 1 reply, has 0 voices.

Last updated by Mihai Apetrei 3 weeks ago.

Assisted by: Mihai Apetrei.

Author Posts
November 29, 2024 at 7:11 pm #16460956

Carl

Background of the issue:
I am developing a site and want to change the language URL format to include country codes like /ca/fr/ and /us/en/ instead of the default format like /fr-ca/ and /en-us/. I am using WPML and have tried modifying the REQUEST_URI in an init hook with the following code: add_action('init', function(){ $_SERVER['REQUEST_URI'] = str_replace('/ca/en/','/en/', $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = str_replace('/us/en/','/en-us/', $_SERVER['REQUEST_URI']); }); However, I cannot modify the permalink.

Symptoms:
I cannot modify the permalink to achieve the desired URL format.

Questions:
Is it possible to change the language URL format to include country codes like /ca/fr/ and /us/en/?

November 29, 2024 at 8:12 pm #16461057

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there! Thank you for reaching out to us.

Right now, we don’t have that type of configuration available, but we’re always working to improve our offerings. If we add more options for the URL format in the future, you can count on us to share the news with a blog post on our site: https://wpml.org/blog/.

Kind regards,
Mihai Apetrei