Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 1 reply, has 2 voices.

Last updated by Bobby 7 months ago.

Assigned support staff: Bobby.

Author Posts
May 9, 2019 at 7:13 pm #3779057

jaredD-2

Hello,

I'm developing a headless multilingual site using the WordPress REST API to access Posts. I'd like to link from one post to it's translated version.

For instance, if requesting
hidden link

Is it possible to retrieve a link, slug or ID of it's translated version in the JSON response?

I believe my issue is similar to the one discussed here:
https://wpml.org/forums/topic/how-to-get-translated-post-via-origin-post-id-through-rest/

although I do not see the "wpml_current_locale" or "wpml_translations" referenced in Marcel's response.

Thank you!

May 10, 2019 at 6:59 pm #3787483

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi There,

after running some tests and consulting with our developers it seems that this is not an expected result that is shown in the ticket here

https://wpml.org/forums/topic/how-to-get-translated-post-via-origin-post-id-through-rest/

The user has used some custom coding to get a specific result back from the wp-rest api

you can do this with custom code , here are some documentations that can help

https://developer.wordpress.org/rest-api/
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

additionally please review the following function another user shared in an older post

if you add it within your theme's functions.php it will enable to show the translates page as well with the original pages all in one page when just calling /posts/

add_action('rest_api_init', function () {
if (defined('REST_REQUEST') && REST_REQUEST) {
add_action('parse_query', function( $q ) {
$q->query_vars['suppress_filters'] = true;
});
}
});

unfortunately as this is custom coding we cannot provide further support within the forum but do recommend contacting our 3rd party contractors

The topic ‘[Closed] Slug or ID of translated post via REST API’ is closed to new replies.