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 4 replies, has 2 voices.

Last updated by Marcel 7 months ago.

Assigned support staff: Marcel.

Author Posts
March 14, 2019 at 9:44 pm #3348641

karinaR

Hello,
is there any chance to get translated post data via origin post id through REST wp-json/wp/v2/pages/ID ?

I tried /hu/wp-json/wp/v2/posts?p=716
or
/wp-json/wp/v2/posts?p=716&lang=hu

but nothing happend.

/hu/wp-json/wp/v2/posts/716 gives me the origin, not translated data.
"hu" is the language code and 716 is some page ID

March 15, 2019 at 5:28 pm #3356001

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi Karina,

Thank you for contacting WPML Support.

hidden link is the correct as you posted, but I was not able to modify this to receive the translated data.

I also tried the solution provided in https://wpml.org/forums/topic/rest-api-posts/, but I was not able to receive the translation. Please control if the post ID 716 is translated to HU, as I see the locale: en_US in the json.

        "wpml_current_locale": "hu_HU",
        "wpml_translations": [
            {
                "locale": "en_US",
                "id": 716,
                "post_title": "Service Sample Post",
                "href": "<em><u>hidden link</u></em>"
            }

Kind Regards
Marcel

March 20, 2019 at 8:32 pm #3393275

karinaR

Hello, yes, that post has translation. Original id is 716 and translated is 720.
Can you delete your screenshots? Threre is an address on it.

March 21, 2019 at 9:38 am #3397433

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi Karina,

sure, I deleted the screenshots and changed the Domain to "URL".
I will try to find a workaround for this, so I will update you when I have something.

Kind Regards
Marcel

March 22, 2019 at 11:56 am #3440061

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi Karina,

after checking this with our 2nd Tier, please use the suggest URL as above and check this JSON response:

    "wpml_translations": [
        {
            "locale": "hu_HU",
            "id": 720,
            "post_title": "Service Sample Post 2",
            "href": "<em><u>hidden link</u></em>"

Here you have the translated post from origin ID 716. Please let me know if this solved your problem.

King Regards
Marcel