Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 7 replies, has 2 voices.

Last updated by Bruno Kos 2 weeks, 6 days ago.

Assigned support staff: Bruno Kos.

Author Posts
November 18, 2019 at 8:03 am #4962479

aurelieM-4

I am trying to:

Use WPML with URL rewriting, because we cannot use any of the standard WPML options to provide the language (lang., /lang or ?lang=). The customer needs this url format for backward compatibility: /%country%/%lang%/page. %country% has no effect on translations and is unrelated to WPML.

We tried to do this:

add_rewrite_tag('%country%', '([^&]+)');
add_rewrite_tag('%lang%', '([^&]+)');

add_rewrite_rule(
'^([a-z]{2})/([a-z]{2})/([^/]*)/?',
'index.php?pagename=$matches[3]&country=$matches[2]&lang=$matches[1]',
'top'
);

But it doesn't work. WPML doesn't seem to be picking the lang parameter, although it is removed from the $wp_query->query_vars.

Link to a page where the issue can be seen:

---

I expected to see:

WPML use the rewritten URL to determine the language.

Instead, I got:

WPML seems to be ignoring the rewritten ?lang parameter.

November 18, 2019 at 9:22 am #4963361

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Can you please check my questions within the previous private reply, which consists of our chat history?

In short, if you're trying to create a custom Language URL format:
hidden link will rg/documentation/getting-started-guide/language-setup/#language-url-format

then I'm afraid it will not be possible, because this is deeply integrated into the core the plugin and may cause incompatibilities in the longer-term.

Regards,
Bruno Kos

November 18, 2019 at 12:21 pm #4964955

aurelieM-4

Hi,

Thank you for your answer.

Yes, this is in essence what we were trying to do.

By extension, does this mean that WPML is incompatible with add_rewrite_rule, and that we shouldn't use it at all, if we want to preserve compatibility ?

Best regards,
Mathieu Renda

November 18, 2019 at 1:34 pm #4965541

Bruno Kos
Supporter

Languages: English (English )

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

Hi Mathieu,

I'm not mistaken, the thing with add_rewrite_rule is that it can cause incompatibilities and it's not easy to implement. Please check at least these few threads:
https://wpml.org/forums/topic/add_rewrite_rule-is-redirecting/
https://wpml.org/forums/topic/add_rewrite_rule-problem/
https://wpml.org/forums/topic/wpml-redirects-to-original-permalink-when-using-add_rewrite_rule/
https://wpml.org/forums/topic/add_rewrite_rule-gets-messed-up-in-secondary-language/
https://wpml.org/forums/topic/add_rewrite_rule-support/

So perhaps if this is not mandatory for your site to function properly, maybe it would be best to avoid this.

However, we could see your exact scenario and how you implemented, but I would need you to show this in our clean sandbox environment, meaning that I will prepare website for you where you could try your code and then explain what is not working and how to reproduce.

I could then send this to our 2nd tier for opinions. Let me know if this would work for you and I will set this all up.

Regards,
Bruno Kos

November 20, 2019 at 11:21 am #4979273

aurelieM-4

We have been trying for multiple days now, read dozens of posts and articles, and we can't get all the routing scenarios to work according to client specifications.

By any chance, do you think could point us to a third-party partner with an experience with WPML + URL rewriting ?

November 20, 2019 at 12:19 pm #4979861

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

I can only point you to https://wpml.org/contractors/, hopefully there will be a contractor who has expertise with these kinds of modifications.

Regards,
Bruno Kos

November 20, 2019 at 2:46 pm #4981409

aurelieM-4

Is there a problem with that page ? As soon as I add any filter, the number of results drops to 0.

November 21, 2019 at 10:22 am #4986753

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Indeed, it seems like there is something wrong with this filter at the moment which is being handled by our team, therefore I suggest you try finding a match manually by checking their areas of expertise. If I may suggest some of them, here they are:

Contractors:
https://wpml.org/contractors/bhi-consulting-for-websites/
https://wpml.org/contractors/boris-hoekmeijer/
https://wpml.org/contractors/kyle-rumble/
https://wpml.org/contractors/kagg-design/
https://wpml.org/contractors/milan-latinovic/

Regards,
Bruno Kos