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

Last updated by Bruno Kos 2 months, 3 weeks ago.

Assigned support staff: Bruno Kos.

Author Posts
March 5, 2019 at 5:58 pm #3275634

maximeF

Hi,
my site is loading content through the REST API. WPML is configured to work on subdomains, one per language.
Standard requests (non-ajax) work fine, they return the correct language.
However, my REST endpoints on each subdomains always return the default language (french in my case).
I'm using the function wpml_get_current_language() to get the current language. On the english subdomain, on a REST endpoint, this function returns 'fr' (=French).

It was working until a recent update (I couldn't tell which one).

Site FR : hidden link
Site EN : hidden link

thanks

March 7, 2019 at 9:04 am #3283004

maximeF

While waiting for an official answer or fix from WPML, I've added this quick hack in my code :

global $sitepress;
if ( preg_match( '/^mice/', $_SERVER['HTTP_HOST'] ) ) {
$sitepress->switch_lang( 'en', true );
}

March 7, 2019 at 12:54 pm #3284496

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Thank you for contacting WPML support!

Can you check this (original reply only):
https://wpml.org/forums/topic/wpml-alters-rest-url-in-translated-lang-leads-to-wp-google-maps-loading-problem/

And these:
https://wpml.org/forums/topic/gutenberg-editor-rest-routes-to-404/
https://wpml.org/forums/topic/incorrect-rest-api-url-in-secondary-language/

Can you tell me if this the same thing you're asking? Because if yes, I've reported this to our 2nd tier recently, however there have been no replies from them yet.

Regards,
Bruno Kos

March 7, 2019 at 1:21 pm #3284665

maximeF

Hi Bruno,

none of your suggestions worked. The ajax cookie checkbox was unchecked. Now it is checked and the issue is still here.

I also tried to add

add_filter( 'rest_url', 'wpml_permalink_filter' );

in functions.php but no effect.

March 7, 2019 at 3:57 pm #3285596

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Yes, possibly that it didn't work as it seems so be another issue after all. I will update this thread as soon as I get more information from our 2nd tier support.

Regards,
Bruno Kos

July 23, 2019 at 1:50 pm #4266625

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

I apologize for not responding for a while.

Can you tell me if you found another way to get this resolved? If yes, I believe we can close this ticket.

Regards,
Bruno Kos