[Resolved] Disable auto translate links in ACF fields
This thread is resolved. Here is a description of the problem and solution.
Problem: You are trying to disable auto-translate links in ACF fields for a site under development and were unable to try the solution from the sandbox provided earlier. Solution: If you're experiencing this issue, we recommend using the
wpml_sl_blacklist_requests
filter to prevent WPML from adjusting links. You should add the slugs of the pages where you want to disable this feature. For example, adding 'test-page-de' will ensure that the DE link remains in the EN page. For more detailed guidance, please check the documentation on linking to pages in a different language here: https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please open a new support ticket at 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.
I did not find a solution to my problem in the code.
We need the URL link in the ACF field from the English page to link to the German page. Even though we don't have automatic translation turned on, it still translates the German URL back to English. We are working with a custom template.
This issue occurs even when we insert an absolute internal URL into the custom ACF block. Once the page is loaded, the URL is replaced.
When we place the URL outside of a link (for example, in a paragraph tag or as simple text inside a div), it shows the correct URL. However, when we insert it in an <a> tag as a link, the problem arises. In our PHP files and in the admin panel, the URL is correct, but on the frontend, after generating the content, the URL is not correct.
1. I created a sandbox site for you.
Have you been able to replicate this issue on the sandbox site?
2. What are the translation settings for this ACF field?
They should be "Copy" if you want the link to be the same on the translated pages.
3. Can you please send me a link to a page on your site where I can see this problem?
Please attach screenshots so I can better understand what to look at.
Also please share your site's Debug information. You can read about it here.
1. I cannot replicate the issue because the ACF Pro plugin is not installed in this sandbox, and I am using a custom template.
2. I have attached the necessary files.
3. I cannot send you a link because the website is currently only in local development.
//Attachments
As you can see, my active language on the site is German (Deutsch), but in the administration, I inserted a link with the English prefix. So, the URL should be "hidden link" instead of "hidden link"
I'm confused. You set the WYSIWYG field to Don't translate." So, how is all the text (even without talking about the link) translated into German? You should not be able to translate it if it is set like this.
Can you please confirm you follow our guides on how to work with the ACF plugin?
I uploaded my settings and block to the sandbox, and I was surprised that my custom language switcher worked. So, I checked the WPML configuration, and we had different settings. For Pages, I had it set to "Translatable – use translation if available or fallback to default language." I tried switching it to "Translatable – only show translated items" according to your setup, and now my custom language switcher works correctly.
I still have an issue, as you can see in the sandbox, where if I insert a link to the same page but in another language, the link changes to the current language. If I insert a different link, it doesn't translate, but if it's a link to the same page in a different language, it gets translated to the current language.
This is Waqas, I'll be looking into this issue while Itamar is on vacation today.
Can you please explain a little more about the following?
... if I insert a link to the same page but in another language, the link changes to the current language ...
Is it about the same WYSIWYG or ACF fields you're trying to insert the link into? Or are you referring to inserting the link directly into page/post content?
Here is the problem: I inserted a link to the German page in the admin, but on the frontend, the URL is translated to the English page. The link is in - "website in german"
hidden link
And in the German version, the problem is the same. I inserted the English link in the admin, but on the frontend, the link is translated to the German one. The link is in - "website in english"
Itamar is OFF; so I will be handling the case. I have checked the issue you reported, and this is expected, if you wish for WPML to not adjust links, you need to use wpml_sl_blacklist_requests filter and add those pages slugs there, for example on sandbox site I have added test-page-de, and it works fine now. There is DE link in EN page.