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

Last updated by danielT-59 9 months, 1 week ago.

Assigned support staff: Carlos Rojas.

Author Posts
January 8, 2019 at 1:54 pm #3067241

maximilianH-7

I am trying to:

Hello,

i am using a wordpress backend with a gatsby static site generator frontend. in the gatsby application i need to generate all pages programatically from the wordpress api response. if i check
hidden link

i only get the pages in my original language but i need the translated pages in that response as well. how can i archive that?

January 8, 2019 at 3:43 pm #3067745

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hello,
Thank you for contacting WPML support.

There is a known issue related to API REST and the latest WPML release. Our specialists are working on this as we speak.

In the mid time the workaround is to include the lang variable in the URL to get the posts in the desired language. In your case you will have to use one URL for each language.

Best regards,
Carlos

January 8, 2019 at 3:47 pm #3067752

maximilianH-7

Hi Carlos, thanks for the response, unfortunately using two url or using parameters in the url is no option for me. i need all pages (original and translated) in the api response because i can only use one base url hidden link

could you please check if there is another solution to this. also how long do you think fixing this will take?

best artur

January 8, 2019 at 3:52 pm #3067771

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi Artur,
Thank you for your message.

At this point -unfortunately- there is no other workaround for this issue. Our specialists are working on the issue but I don't have an estimated time of arrival for a solution.

Thank you very much for your understanding.
Best regards,
Carlos

January 8, 2019 at 4:07 pm #3067849

maximilianH-7

could i downgrade to an older version of the plugin in the meantime?

January 8, 2019 at 4:30 pm #3067961

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,

Yes, you can. I recommend you to test the downgrade in a staging site first in order to avoid any issue in the live site.

Regards,
Carlos

January 8, 2019 at 5:03 pm #3068136

maximilianH-7

which version should i use which does not include this bug but still compatible with wordpress 5?

January 8, 2019 at 5:32 pm #3068268

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,

I will consult our specialists about this and I will get back to you as soon as I have an answer.

Regards,
Carlos

January 9, 2019 at 1:33 pm #3071905

maximilianH-7

Hey carlos do you have some information regarding this issue already?

January 9, 2019 at 5:09 pm #3072937

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,

Please add this code to functions.php file to solve the issue:

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

Could you confirm that the issue is solved?
Regards,
Carlos

February 19, 2019 at 8:26 am #3215401

antonioP-36

Hello,
sorry if hijack the post but I am looking for the same thing.
Is today the issue solved? Where can I find the articles associations via REST API?

August 1, 2019 at 7:26 am #4319259

danielT-59

Hi there,

I have the exact same problem and an option in WPML would be nice, that gives you the possibility to choose if all languages are served under the the normal api response or not.

Also, I think it would make more sense to get all translations under `wp-json/wp/v2/posts`
and a specific translation you can still get at `wp-json/wp/v2/posts/?lang=en` or `en/wp-json/wp/v2/posts`

@carlos-r, are you sure that the action you posted doesn't interfere with for example the "ACF to REST API" Plugin?