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

Last updated by jurgenN 1 year, 8 months ago.

Assigned support staff: Bobby.

Author Posts
February 25, 2018 at 9:57 pm #1528635

winfriedH-2

Hi there,

I run a website in german/english, german being the primary language.
Different languages in directories are set as language URL format.

So the page urls look something like this:

hidden link
hidden link

And I am using the Translation Editor to translate the content.

Now, on some english pages I need to link to the german page, but I don't know how to do this, as WPML automatically changes the german urls to english.

For a better understanding:
Say I am on the page 'domain.de/german-slug'.
I go to the Translation Editor and translate my text to English.
There I comment: "More Information only available in German", setting a link to the German page (domain.de/german-slug).
I save the page.
Now I go to the english website and click on the link "More Information only available in German", but the link to the german page has automatically changed to 'domain.de/en/english-slug'. – So I am stuck. The page just reloads.

What I tried next:
I tried to set the link not via Translator Editor but manually. I went via WordPress to the english page and set the link there and saved the page. This worked. But only until I made changes to the original page in German. The moment I did that, the link on the english page linking to the german page linked again to the english page.

Is there some Setting in WPML, where I can set: "Don't you dare touch links I set in my text"? ,-) I couldn't find it.

Thank you in advance and best regards!

P.S.
- I don't use Sticky-Links.
- I am running the latest WPML and WordPress-Version
- I searched the forum but didn't find a solution for my problem...

February 26, 2018 at 8:36 pm #1529763

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

Please provide you WPML Debug information in the debug field below? http://wpml.org/faq/provide-debug-information-faster-support/

If possible please use the add-on plugin WPML Sticky Links and let me know your results

https://wpml.org/download/wpml-sticky-links/

February 26, 2018 at 10:57 pm #1529862

winfriedH-2

Hello Bobby,
you talk about a debug field and in the guideline there is a screenshot whit this field, but I can't find it here. (See attached image.)

February 26, 2018 at 11:20 pm #1529868

winfriedH-2

And I read about the WPML Sticky Links Plugin, but as far as I understood the only thing it does is to take the IDs for an url instead of a text slug to avoid broken links and 404 pages, when the user messes up the slugs.
As I don't do that I see no point in using this plugin. Also, it's easier for me to see where a hyperlink links to reading a text slug instead of having something like /?page_id=519. And I might be wrong, but as far as I know it is also more SEO friendly to have text in the links instead of using IDs.
I just can't see how Sticky Links would solve my problem.

February 27, 2018 at 5:46 pm #1530914

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Please provide me with the specific links that you are reffering to and if possible i would like to take a closer look.

**Before we proceed I recommend to please take FULL BACKUP of your database and your website.**
I often use the Duplicator plugin for this purpose See: http://wordpress.org/plugins/duplicator/

I would like to request temporary access (wp-admin and FTP) to your site to fix the issue.
(preferably to a test site where the problem has been replicated if possible)

You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you will enter is private which means only you and I can see and have access to it.

February 27, 2018 at 8:38 pm #1531092

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I went to edit the page, then viewed the link in the HTML instead of visual , changed the URL to the correct one "hidden link" and updated.

now it works as expected in the front end.

Note : you have to access the EN page through the WP Standard Editor.
you can do this by going to the default page and clicking "edit" then using the language switcher in the top header to change the language.

February 27, 2018 at 11:14 pm #1531190

winfriedH-2

Hi Bobby,

but that is exactly what I've done and what I explained to you, when I opened this ticket. And as I said:

"...This worked. But only until I made changes to the original page in German. The moment I did that, the link on the english page linking to the german page linked again to the english page."

This is step by step, how the links you just set get changed automatically:

1. Client goes to this german page and edits any text on the page, for example just the headline „Übersetzte Bücher”.
2. Client saves the page.
(Now the pencil symbol has changed to the blue circle with the arrow.)
3. Client clicks on the circle and gets to the WPML Translation Editor.
4. Client translates/updates just the field with the new headline.
5. Client saves the changes
6. BOOM! All the Links to the german page in the other fields do not longer link to the german page, but to the english page.

I just tested it again. The hyperlinks link to the english page again.

February 28, 2018 at 7:45 pm #1532267

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

The issue is resolved if using the standard WP editor.

There seems to have been a compatibility issue or some sort of caching issue between the translations in the WPML Translation Editor and the WP standard editor.

for example, the Translation Editor would not be updating the front end anymore since you started using the standard WP backend editor

this was tested by adding a new duplicate of those fields which worked as expected.

Then i went to WPML->Translation Management->Multilingual Content Setup->"Translate Manually" and test the links again and they worked well.

i used your above steps to test them.

March 1, 2018 at 12:17 pm #1533058

winfriedH-2

Hello Bobby,
thank you for your tests, yet it seems we are talking at cross purposes.

It goes without saying that by deactivating the WPML Translation Editor there will be no issue with the Translation Editor. You can't have an issue with something you don't use.

But my client (a writer and translator) uses the WPML Translation Editor.
Exactly because of the reasons you write in the WPML documentation:

"…When you use manual translation, you need to take care of all technical issues related to translation. This is why manual translation is best suited for developers who are building sites and only create small amounts of content.
When you need to manage large amounts of content, including its translation, you should look at either using WPML’s Translation Editor or professional translation…."

So unfortunately the issue and question remains the same:

How can we set a link to the german page while using the translation editor?
Is there a setting to tell WPML not to change content Links automatically?
Or is there a code to put into function.php?
Or is there another solution?

---
You overlooked my question about the Debug information field. Could you please tell me where to find it? I surely will need in the future.

Thank you and best regards!

March 1, 2018 at 7:24 pm #1533627

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I have enabled the WPML Translation Editor.

The following workaround can be applied so your client can avoid breaking the URL's.

this only happens when changes are made to the default language and then accessing the translation through WPML Translation Editor and saving, this is because it fully resets the links to point to the correct language (since they are pointing to the 'wrong lang' (de) ).

quick way to avoid this is the following.

Once changes are done in the default language , you can use the language switcher in the top header and switch to English then just click update and close the page.

this wont break the links and it allows you to keep using the String Translation.

For the debug information , it requires me to enable it now.
I have enabled it , let me know if you see it.

it should give you a field to paste it.
http://wpml.org/faq/provide-debug-information-faster-support/

March 2, 2018 at 7:36 pm #1534796

winfriedH-2

Hello Bobby,

basically you have told me the same thing again but with other words: use the WP Editor instead of the WPML Translation Editor.
But as I said, my client only uses the WPML Translation Editor.

Your approach to avoid the problem, instead of solving it, is not helpful for us. Not only would it be confusing for the client to use both editors, if the client combines both, things can get really messed up. (For example: I saw that if I make changes to the german page, then go to the english page and make changes there and save it and then go to the german page and click to the Translation Editor the text fields/elements edited in the WP Editor don't show up at all.)

As you could not help me I kept on researching by myself. The best I could do is to build a workaround designing a Custom Language Switchers Using Template Files. (https://wpml.org/documentation/getting-started-guide/language-setup/designing-custom-language-switchers-using-template-files/)

I followed the instructions and made a simple text-link-language-switcher that my client now can insert as the [wpml_language_selector_widget] shortcode into the text. It's not a perfect solution, as we can only link to the same page and can't edit the text of the link, but it's the best I can do. (I am only a designer.)

I also found the ticket https://wpml.org/forums/topic/how-to-link-to-the-same-page-in-another-language/showing a shortcode like [wpml_lang id="1495" lang="es" text="Read in Spanish"] and this would be much better solution, although I didn't understand what was explained in that ticket. I thought: Maybe if I activate "Links to translation of posts", then put the code into functions.php and use the shortcode it works, but it didn't. So I obviously didn't understand it at all.

Maybe you could explain to me how to link to another language via a shortcode like [wpml_lang id="1495" lang="es" text="Read in Spanish"] ?

Thank you very much
and best regards.

March 2, 2018 at 9:34 pm #1534859

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

I have test the short code provided and it worked but just gave the default language id back which is not what you wanted.

If you would like i can help you implement the following shortcode thats based of the one you saw

Do note that we cannot support custom work on the forum but the following should be able to help you.

If you go to hidden link for the third item i have added the shortcode [german_add] and it links to the German page.

the shortcode was added at the end of your theme's functions.php (already added there)

//function added by WPML
function link_languages($atts) {
	extract(shortcode_atts(array(
		'id' => 1443,
		'text' => "German"  
    ), $atts));
    
    if ($text) {
        $url = "<a href='<em><u>hidden link</u></em>' target='_blank'>German</a>";
                return $url;
    } else {
	   return get_permalink($id);
	}
}
add_shortcode('german_add', 'link_languages');

if this is working ok all you need to do is just add the [german_add] shortcode.

I have test this by updating the page and it works well.

Note: I hope you understand that i have test this locally with 2 different environments and as this is not a bug within the WPML plugin , a custom approach had to be taken.

i have provided the above solution as a spinoff of the one you provided me but any further custom work cannot be covered within the forum.

March 3, 2018 at 9:16 pm #1535267

winfriedH-2

Hello Bobby,

I am a designer that can't program even a single line, but between the other ticket, your code and two hours of trail and error (not knowing what I am doing) I now found the perfect code for a shortcode workaround.

I deleted your code in the functions.php of the theme and inserted this into the functions.php of the child-theme:

// INTERNAL LINK TO OTHER LANGUAGE

function link_to_language($atts) {
	extract(shortcode_atts(array(
        'url' => '',
        'text' => ''
    ), $atts));
    
        $link = "<a href='$url'>$text</a>";
                return $link;
}

add_shortcode('hardlink', 'link_to_language');

Now, if my client wants to link to any page on another language without WPML changing the link, she only has to insert a shortcode with an url and link-text that looks something like this:

[hardlink url="<em><u>hidden link</u></em>" text="linked-text"]

——

If what I thought to be a bug is a feature, I would like to make a feature request to WPML:
A setting in the WPML Translation Management that allows the users to decide if WPML will convert content links or not.
Could you please forward this request to the developers?

I want to thank you very much for your time and thoughts on this topic.
Although it was a long way and I felt frustrated by your answers, without your input I wouldn't have come to this solution!

I hope other people with the same issue will benefit from this ticket.

Best regards!

July 5, 2019 at 11:13 pm #4154127

jurgenN

I found out that adding class="wpml-ls-link" to a link, the link bypasses the sticky link function and just executes the link as entered. Much easier than changing functions.php and using shortcodes.