Skip Navigation

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

Problem:

How to add a link to pages in a different language.

Solution:

You need to add the following example code in the functions.php file of your site's theme.

add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );
  
function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
    $blacklist[] = 'documentation';
    return $blacklist;
}

In this example, 'documentation' represents the slug of the page you link to and don't want to take the user to the translation of this page. Please read more about this function in our documentation here.

https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language

Note:

1. You do not need to activate the Sticky Links add-on.

2. For existing pages and posts with links in their content, you might need to make a small change on the page and press the Update button. And then also update the translation.

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

Last updated by Itamar 3 years, 11 months ago.

Assisted by: Itamar.

Author Posts
November 1, 2020 at 3:58 pm #7353147

mikeD-5

Don't translate links

November 1, 2020 at 6:21 pm #7353369

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

Please check my suggestion and reply here if you need more help with this issue.

Thanks,
Itamar.

November 1, 2020 at 9:41 pm #7353605

mikeD-5

Can you clarify what this means please?

Screen Shot 2020-11-01 at 4.39.52 PM.jpg
November 1, 2020 at 9:52 pm #7353639

mikeD-5

I can also confirm that using the WP editor directly instead of the WPML translation system does NOT fix the problem.

November 2, 2020 at 8:45 am #7355595

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

I've discussed this issue with our second tier supporter and there is a way to achieve what you need. You need to add the example following in the functions.php file of your site's theme.

add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );
 
function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
    $blacklist[] = 'documentation';
    return $blacklist;
}

In this example, 'documentation' represents the slug of the page which you link to and don't want to take the user to the translation of this page. Please read more about this function in our documentation here.
https://wpml.org/documentation/getting-started-guide/sticky-links/#linking-to-pages-in-a-different-language

Note:

1. You do not need to activate the Sticky Links add-on.
2. For existing pages and posts that have links in their content you might need to make a small change in the page and press the Update button. And then also update the translation.

Please let me know if you have further questions about this issue.

Regards,
Itamar.

November 2, 2020 at 2:24 pm #7358875

mikeD-5

That did the trick. If I can make a suggestion, it would be to be able to do this without a filter. For example, a specific data attribute on the link like 'data-no-translation' or something.

November 2, 2020 at 2:37 pm #7358991

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

I'm glad that this helped you solve the issue.

At the following link, you can submit a feature request that goes directly to our developers.
https://wpml.org/suggest-a-new-feature-for-wpml/
They will consider whether it is possible or needed to add this feature.

If you consider this issue as resolved please mark this ticket as resolved.

Cheers,
Itamar.

November 9, 2020 at 2:30 pm #7409189

mikeD-5

For future visitors: this ticket was started via a chat, and the chat record is hidden. So here is a summary.

TL;DR: There is no way to prevent WPML from translating a link to a page in the default language.

I have a site with several languages, and in this site I have a page that has been translated using the WPML translation system. At the top of this page I have a block of text that says "This page is avaialble in the following languages:" followed by a list of the site languages, and each lang name is linked to the translated copy of the current page.

So for example for FR I have
/fr/award-recipient/this-years-winner/
but for EN I have
/award-recipient/this-years-winner/
(note that the language is not part of the link)

When I view this page in any language that is not EN, the EN link is being translated into the language of the current page automatically. This is not what I want.

This seems to be because the system is converting a link to the default page language (EN) found in the translated text, into the translated link link for the page

To duplicate, you can do the following
1. In an EN site, make a new page and translate it into FR
2. add dummy content and confirm that both pages work correctly in the front end.
3. In the post content, add a link to the EN page without the domain, into each page content

Result: EN page links to EN, FR page links to FR (not EN as desired)

Said another way: how can I add a link in the post content, to a specific page in the site default language, without that link being translated? IOW I want to link to the EN page from a FR page, but when I try the EN link is being translated into FR and I do not want this to happen.

What seems to be happening is that the pasted page link to the default content is being converted by the WPML system into the default permalink format (in this case, /?p=911), which is then translated into the localized content.

November 16, 2020 at 2:56 pm #7459013

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi and sorry for missing your reply here.

Thanks a lot for adding the above information to this thread.

Please let me know if you need more help with this issue.

Regards,
Itamar.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.