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

Last updated by ericS-63 1 month ago.

Assisted by: Christopher Amirian.

Author Posts
March 2, 2025 at 12:53 pm #16765508

ericS-63

Background of the issue:
I’m using ACF shortcodes on my WordPress site, but they don’t seem to translate correctly with WPML. The shortcode retrieves the field value, but it always displays the original language instead of the translated version. Site under development. Video: hidden link

Symptoms:
ACF shortcodes are not translating correctly with WPML, displaying the original language instead of the translated version.

Questions:
Is there a recommended way to make ACF shortcodes work with WPML translations?

March 2, 2025 at 1:17 pm #16765523

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Welcome to WPML support.

the issue with ACF shortcode is that you use direct Post ID but WPML creates other post IDs for the translations,

I wonder what happens if you search for the ID of the post in the advanced translation editor?

Do you see the post ID there? If so you will need to most probably add the translate post ID there.

To find the translated post id go to the post in edit mode in the original language, from the top admin bar change the language to the translated one, and check the browser address bar to see the ID for the translated post

Also, please provide the debug information:

https://wpml.org/faq/provide-debug-information-faster-suppor

March 2, 2025 at 2:33 pm #16765741

ericS-63

Hi,

Thanks for your quick response!

Did you watch my screen-recorded video?

The whole idea is that WPML should automatically retrieve the correct post ID for any given language. It cannot be that uncommon to translate ACF fields that are placed using shortcodes or other dynamic data editors.

Interestingly, it works and translates fine inside Gutenberg query loops, so there must be some kind of logic in WPML that maps one post ID to its translated version automatically.

Could you provide guidance on how to achieve the same behavior when using ACF shortcodes? Is there a built-in function in WPML that should be used to retrieve the translated post ID dynamically?

Looking forward to your advice.

March 3, 2025 at 2:42 pm #16769572

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for the reply. I tired to test the same scenario by adding a new WordPress installation.

Here is the login link:

hidden link

I installed ACF and added a field group to the normal post. Then added a text field called hello.

Added content to the post and tried to call it using shortcode both from the post itself without the post_id in the shortcode and from a test page with post_id in the shortcode but nothing shows.

I also added the code in the ACF documentation to the theme functions.php to enable the shortcode feature.

But it is still now showing.

Maybe if you can check what I am doing wrong so I can test?

Thanks.

March 4, 2025 at 10:40 am #16773147

ericS-63

Strange, I did'nt get it to work or your site either.

But I maged to break the site with this code:
$hello_value = get_field('hello', get_the_ID());
var_dump($hello_value);

Maybe I should invite you to a SANDBOX that is a copy of our working site?

March 5, 2025 at 2:57 pm #16779601

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you for your patience, the problem with that approach would be that I can not send any report to the second tier support as they will need a clean installation to work on.

I wonder if you could check on this installation too?

This time I did not activate WPML at all and you can install ACF and check. I just need the shortcode to be working ok and then I will be able to setup WPML later for testing:

hidden link

Thanks.

March 10, 2025 at 8:51 am #16794983

ericS-63

I did'nt get ACF "autotmatic" shortcode to work so a hard coded one. Please test if you get that one to translate.

The field is placed inside Posts.

March 11, 2025 at 1:20 pm #16801939

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you. I installed WPML Multilingual CMS, WPML String Translation and Advanced Custom Fields Multilingual plugins.

Then went to ACF > Field groups and inside the field group I made sure that the "Same fields across languages" option is selected and clicked save.

Went back to the Hello world post and translated it and it shows the content with no issues for translation with the hardcoded method that you used:

Would you please check?

hidden link

Thanks.

March 12, 2025 at 5:19 pm #16808709

ericS-63

Yes, agree. No problem there. I have switched the way I use the shortcodes not so also for me the problem does not longer exist. Thanks for the support.