This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is developing a bilingual site (EN + FR) using WordPress and WPML plugins and is trying to fetch data for a custom post type called 'news-post' using the REST API. However, they are unable to retrieve both English and French data for the 'news-post' custom post type.
Solution:
If you're experiencing this issue, we recommend trying the following steps:
1. To access the French data for your custom post type, append '/fr' to your REST API URL like this:
https://***.ca/fr/wp-json/wp/v2/news-post/
.
2. If you need to retrieve the translated ID in the REST API response, you can use the wpml_object_id hook. This hook allows you to retrieve the corresponding translation of a post, page, or custom post type in the desired language. You can then modify the API output using a filter like rest_prepare_post to include the translated version’s ID based on the specified language.
For more detailed information on working with WPML tables and hooks, you can check the following documentation:
Please note that this solution might be irrelevant if it’s outdated or not applicable to your case. 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 the issue persists, please open a new support ticket.
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 3 replies, has 0 voices.
Last updated by 1 month, 2 weeks ago.
Assisted by: Marcel.