Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
ACF fields link translations aren't applied properly.

Solution:
If you're experiencing issues with ACF fields link translations not being applied correctly, we recommend using WPML hooks to modify the URL to the current language.

Here's a step-by-step guide:
1. Retrieve the subfield link using

$b_link = get_sub_field('link');

2. Apply the WPML filter to fix the translated URL with

$translated_url_fix = apply_filters('wpml_permalink', $b_link['url']);

For more information, please refer to the WPML hook documentation.
If this solution doesn't seem relevant to your issue, please open a new support ticket in the WPML support forum.

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

Last updated by Shekhar Bhandari 11 months, 2 weeks ago.

Assisted by: Shekhar Bhandari.

Author Posts
December 19, 2023 at 1:48 pm

dennisv-7

ACF fields link translations aren't applied properly

December 19, 2023 at 3:15 pm
December 19, 2023 at 4:18 pm #15095063

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Upon checking further, I noticed that this is a known issue and is escalated to our developers.

Until the issue is fixed I suggest you use wpml hooks to modify the URL to the current language to fix the issue.

$b_link = get_sub_field('link');
                  $translated_url_fix = apply_filters('wpml_permalink', $b_link['url']);

                  if ($b_label && $b_link) : ?>
                    <a class="butn butn-<?= $b_variant ?>" href="<?= $translated_url_fix ?>" target="<?= $b_link['target'] ?>">

https://wpml.org/wpml-hook/wpml_permalink/

Let me know if this helps.

Thanks

December 19, 2023 at 4:39 pm #15095341

dennisv-7

Hello Shekhar,

I've added the code to the buttons. And maybe it is not the best way. But at least the visitors stays on the correct domain and visit the correct page in the correct language. For example the button we discussed in the chat now leads to hidden link and that link redirect the visitor to hidden link. Which is the correct page.

December 19, 2023 at 4:58 pm #15095451

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Glad to know that it's working.

December 21, 2023 at 10:52 am #15109073

dennisv-7

Hello Shekhar,

With another newly installed website we have the same issue.
The NL URL: hidden link
The EN URL: hidden link

This site is not finished yet. So the maintainance mode is still active. I can give you some login data.

Do I have to add that filter code to this site also? Or is more known about this problem?

December 22, 2023 at 4:05 am #15113955

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Yes, you have to add the filter to the new site too.

Thanks