Skip Navigation

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

Last updated by afifJ-2 1 year, 11 months ago.

Assisted by: Waqar Ali.

Author Posts
June 20, 2023 at 5:42 am #13855427

afifJ-2

i have a acf group added to custom post and when i am tryying to get_fields its always return the origfnal value and didn;t get he value stored per custom post language..

June 20, 2023 at 8:30 am #13856817

Waqar Ali

Hi,

Thank you for contacting us and I'd be happy to assist.

Assuming that your website already has the 'Advanced Custom Fields Multilingual (ACFML)' plugin activated.

If you're using the 'get_fields' function without passing the target post's ID, WPML should automatically filter the current post's ID, so that value from the current language post is fetched.

And if your code is passing a specific page/post's ID or needs the value from a language other than the current one, you'll need to use the 'wpml_object_id' filter, so that the correct language's page/post ID is used.
( ref: https://wpml.org/wpml-hook/wpml_object_id/ )

For example:

get_field( FIELD_NAME, apply_filters( 'wpml_object_id', get_the_ID(), 'page', TRUE,'en'  );

I hope this helps and please let me know if you need further assistance.

regards,
Waqar