This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is using a decoupled website with a Next.js/React frontend and a WordPress backend, attempting to access different translations of a post via the WordPress REST API. They are facing issues when adding the query parameter 'lang=de' to fetch German translations, as no translation information appears in the JSON object.
Solution:
To fetch all pages in a specific language, such as German, from your WordPress site, you can use the following API endpoint:
/wp-json/wp/v2/pages/?lang=de
If you need to check if the original content has translations, consider using PHP with the following WPML hooks:
- https://wpml.org/wpml-hook/wpml_get_element_translations/
- https://wpml.org/wpml-hook/wpml_element_trid/
Remember, each translation has its own ID, so you might need to query for the ID of the translated post to access specific translations.
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 at https://wpml.org/forums/forum/english-support/.
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.
This topic contains 5 replies, has 0 voices.
Last updated by 6 months, 3 weeks ago.
Assisted by: Andreas W..