Skip Navigation

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.

WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 3 replies, has 0 voices.

Last updated by Dražen Duvnjak 1 day, 4 hours ago.

Assisted by: Dražen Duvnjak.

Author Posts
November 27, 2024 at 8:27 pm #16451616

tinaM-8

Background of the issue:
I have a headless WordPress setup and I am pulling page content via the REST API. I can load the default language content fine, but when I request translated content, it just returns the default language. For example, if I access: /wp-json/wp/v2/pages?slug=about-us&lang=en_CA I get the default language's content, not my translated content. However, if I am logged into WordPress and I access the URL, I do get the translated content.

Symptoms:
Translated content is not served through the REST API unless logged in as an administrator.

Questions:
Is there a way to allow the translated content to be served without being logged in as an administrator through the API?

November 28, 2024 at 8:06 am #16453259

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for contacting us.

If it works when logged in, it should also work when not logged in, I just tested it.

1) Can you please check your translated pages are translated 100% and published?

2) Can you please check if you have not set to hide the 2nd language from WPML > Languages?

Regards,
Drazen

Slika zaslona 2024-11-28 u 09.04.30.png
November 28, 2024 at 2:21 pm #16455697

tinaM-8

My pages are translated. I have the about-us page, for the "en" language (default) it is ID 12, for my translation "en_CA" the ID is 51.

If I access /wp-json/wp/v2/pages?slug=about-us&lang=en_CA from the browser I am logged into wordpress as I get page with ID 51.

If I access /wp-json/wp/v2/pages?slug=about-us&lang=en_CA while I am not logged in I get a page with ID 12.

The language is not set to hidden. Every thing is published and translated.

November 29, 2024 at 7:51 am #16457983

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

thanks for getting back.

I checked further, you need to language code before the REST API path, so not at the end, but for example like this:

<em><u>hidden link</u></em> 

and then it works fine.

Please check.

Regards,
Drazen