Skip Navigation

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

Problem:
Client needed to make the Yoast SEO Canonical URL field translatable in the Advanced Translation Editor to ensure that the correct canonical URLs are used for different language versions of a page.

Solution:
We recommend registering the canonical URL field for translation by adding custom XML configuration in WPML. Here are the steps to follow:
1. Navigate to WPML > Settings in your WordPress dashboard.
2. Scroll down to the Custom XML Configuration section.
3. Insert the following code:

<wpml-config>
    <custom-fields>
        <custom-field action="translate">_yoast_wpseo_canonical</custom-field>
    </custom-fields>
</wpml-config>

This will allow the Canonical URL field to be translatable within the Advanced Translation Editor. For more information on custom XML configurations, please refer to our documentation on language configuration files.

If you need to quickly edit the canonical URL, you can do so by:
1. Going to Pages and editing the page in question.
2. Using the language switcher at the top header to switch to the translation.
3. Manually editing the Canonical URL field (disregard any warnings).

If this solution does not seem relevant to your situation, please feel free to open a new support ticket in our 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 3 replies, has 2 voices.

Last updated by Bobby 1 year, 5 months ago.

Assisted by: Bobby.

Author Posts
November 1, 2023 at 1:19 pm #14707813

madsG-2

Is it possible to make the Yoast field Canonical URL translatable in the Advanced Translation Editor?

On a couple of websites I need to change the Canonical URL's to be the corresponding Default page for the translated pages (in English).

Right now my workaround is switching the pages to "Translate independently" and then changing the Canonical URL, but that is not a good solution as we would like to use Advanced Translation Editor.

The reason we want to change Canonical URL's is a bit difficult to explain but I'll try:
Google is showing the English pages in stead of the Danish pages for search phrases with English terms - even though the users are Danish and would prefer the Danish pages.

November 3, 2023 at 8:57 pm #14728795

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hi there,

At the moment there is no out of the box setting that would add the canonical to the ate editor.
You can attempt registering it with a custom config.xml file as shown here:
https://wpml.org/documentation/support/language-configuration-files/ (Please do note this is custom work that is outside of our support coverage)

To quickly edit it you can go to pages -> edit your page -> use the language switcher at the top header and switch to the translation (dismiss the warning) -> manually edit.

November 6, 2023 at 11:28 am #14736997

madsG-2

Ok, thanks.

Looks like I have found a solution that I'll share here.

I have registered the canonical URL field by adding the following in Custom XML under WPML > Settings:
<wpml-config>
<custom-fields>
<custom-field action="translate">_yoast_wpseo_canonical</custom-field>
</custom-fields>
</wpml-config>

November 6, 2023 at 10:30 pm #14742381

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Thank you for sharing the XML solution, I am glad to hear that it is working as expected now!