Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 3 months ago.

Assisted by: Christopher Amirian.

Author Posts
August 16, 2024 at 2:16 pm #16078567

manojP

Background of the issue:
I am trying to resolve an issue with the canonical URL of my site. The site’s original language is Dutch, and I have used the WPML plugin to translate it to English. In English pages, the canonical URL is shown properly, but in Dutch pages, the canonical URL fetches the respective English page URL instead of the original Dutch URL. I tried using the following code to modify the canonical URL structure, but it did not work:

add_filter( 'aioseo_canonical_url', 'aioseo_filter_canonical_url' );

function aioseo_filter_canonical_url( $url ) {
//   if ( is_singular() ) {
    //   return '';
//   }
    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "<em><u>hidden link</u></em>" : "<em><u>hidden link</u></em>";
    $current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    // $url = get_current_url();
    return $current_url;
}

Link to a page where the issue can be seen: hidden link

Symptoms:
The URL of the site should be the canonical of the page, but instead, the translated pages, i.e., the respective English page URL, are fetched for canonical in Dutch pages.

Questions:
Why is the canonical URL of the Dutch pages fetching the respective English page URL instead of the original Dutch URL?
How can I modify the canonical URL structure to show the correct URL for Dutch pages?

August 17, 2024 at 7:55 am #16079750

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

You should not have problems with Conanical URLs and you should not add code for that.

Would you please do as follows?

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to "WordPress Dashboard > Plugins > Add new > Commercial (tab)".
- Click the "Check for Updates" button.
- Check the WPML SEO plugin and download and activate it
- Go to "WordPress Dashboard > Settings > Permalinks".
- Click the "Save" button to flush the permalinks cache.

Thanks.

The topic ‘[Closed] Canonical URL Issue’ is closed to new replies.