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 thread is resolved. Here is a description of the problem and solution.

Problem: The user asks for WPML hooks that will help him implement some custom REST API endpoint Solution: We can use the following hooks to retrieve language data or switch language during the request "wpml_active_languages" and "wpml_switch_language" Relevant Documentation: https://wpml.org/wpml-hook/ https://wpml.org/wpml-hook/wpml_active_languages/ https://wpml.org/wpml-hook/wpml_switch_language/

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Dan 2 months, 2 weeks ago.

Assigned support staff: Jamal.

Author Posts
July 29, 2019 at 1:52 pm #4300469

Dan

I am creating a site in which I need to pass data to rest API so they can use it for mobile application. I want it to use translated strings for 8 different languages. When I access the site I am able to see the translated strings. Below is my example route call.

register_rest_route('discover', '/getdiscoverlist', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => 'getDiscoverList',
));

in getDiscoverList I am fetching data for the custom discover post type. Can you please help which filter or hook I can use to fetch preferred data for particular language using my API

August 8, 2019 at 6:24 am #4359939
Dan

Hi, Can you please guide how to fetch the translated category. When I pass translated term ID to get_term function it is fetching English version only.

New threads created by Jamal and linked to this one are listed below:

https://wpml.org/forums/topic/rest-api-fetch-the-translated-category/

August 8, 2019 at 8:09 am #4360699

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello,

Sure. However, for support rules, we are able to handle only one issue at the time. This helps us to bring you a better service and also help other users to find all the information here exposed.
For that reason, I have created a new ticket for this question and I'll be posting my replies there.
If you still need assistance with your first request, please reply here. Otherwise, please mark this ticket as resolved and we'll continue in the newly created one.

Best regards,
Jamal

August 8, 2019 at 9:34 am #4361515

Dan

My issue is resolved now. Thank you!