Skip Navigation

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

Problem:
The client needs to modify the language URL format to include country codes like /ca/fr/ and /us/en/ in their WordPress site using WPML. They attempted to modify the

REQUEST_URI

in an init hook but were unable to change the permalink structure as desired.
Solution:
We informed the client that achieving this URL format with WPML directly is not possible without additional custom coding. Since this requires complex code and might cause side effects, we recommended hiring a WPML contractor for professional assistance. You can find a suitable contractor by visiting https://wpml.org/contractors/.

Please note that this solution might be outdated or not applicable to your specific case. If this does not resolve your issue, 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. If you still need assistance, please 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.

Tagged: 

This topic contains 1 reply, has 1 voice.

Last updated by Dražen 3 weeks, 5 days ago.

Assisted by: Dražen.

Author Posts
November 29, 2024 at 7:07 pm #16460955

Carl

<b>Background of the issue: </b>
I need to make the language URL format like this:
hidden link,
hidden link,
hidden link.

I can modify the REQUEST_URI in an init hook, but I cannot modify the permalink. Here is the code I am using:
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']);
});

<b>Symptoms: </b>
I cannot modify the permalink.

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

December 2, 2024 at 6:52 am #16464253

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I am afraid it is not possible with WPML out of the box, probably you should use some custom code, but I can not suggest since it will need more complex code and check if it causes any side effect. I can advise hiring WPML contractor:

https://wpml.org/contractors/

Regards,
Drazen