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

Last updated by Bruno 3 months ago.

Assigned support staff: Bruno.

Author Posts
July 10, 2019 at 3:06 pm #4181937

davidH-81

I am using Advanced Custom Fields plugin.

My ACF fields are translated within Custom Fields (ACF) section and not in WPML - String Translation (because it didn`t occur there).

I want to use those ACF fields with AJAX. I have a call back function, where the result is an object with the languages.

On the Frontend I call it and I get back the result on the English page and those values are in English.

However I try it in German, Spanish or another site the translation are not working. I enabled this: "Store a language cookie to support language filtering for AJAX ", but did not solve my problem.

My request is how I can translate those ACF fields when I am using them by AJAX?

Important can be: I use get_field_object() function and out of loop.

Thank you!

July 10, 2019 at 10:24 pm #4184661

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

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

Thank you for contacting us. This will depend on how your site is being done and how AJAX calls are being made.

Depending on how this was done, within the AJAX call you will even need to pass the language code so that you can have it working as expected.

Accessing your site, what steps should I take to see the problem you are reporting?

Thank you.

July 11, 2019 at 8:57 am #4187643

davidH-81

I passed the language code in the call back function

 lang=de 

, and when I dump the language code I can see the current language, but I still get English text with get_field_object(). The second parameter is the

 $post_id 

, I gave German $post_id, but nothing happen. What do you think why? It seems get_field_object() doesn`t see the current language.

The topic ‘[Closed] ACF fields by AJAX do not work’ is closed to new replies.