Case Study: Resolving Incorrect Canonical URLs on a Large Multilingual WPML Website

The Problem

I was working on a large multilingual WordPress website powered by WPML and Yoast SEO.

The website consisted of:

  • 1,600+ parent pages in English
  • Multiple translated versions across 9 additional languages
  • Thousands of translated pages created using WPML Duplicate Translation

During an SEO audit, I discovered that every translated page was generating an incorrect canonical URL. Instead of referencing its own translated URL, the canonical tag pointed to the English parent page.

For example:

Expected Canonical

https://example.com/fr/about-us/

Actual Canonical

https://example.com/about-us/

This created a significant multilingual SEO issue because search engines could interpret the translated pages as duplicates of the English version, reducing the likelihood of individual language pages being indexed correctly.

The Solution

Rather than converting thousands of WPML duplicate pages into independent translations, a process that would have required editing every translated page individually, I investigated how Yoast SEO generated canonical URLs.

Using Yoast’s wpseo_canonical filter, I implemented a lightweight custom PHP solution that forced each translated page to output its own permalink as the canonical URL.

The solution:

  • Preserved all existing WPML translation relationships
  • Required no database modifications
  • Avoided converting duplicate translations into independent pages
  • Automatically applied to existing and future translated pages

Code Implementation

				
					/**
 * Force self-referencing canonical URLs for WPML translated pages.
 * Works with Yoast SEO.
 */
add_filter( 'wpseo_canonical', 'custom_wpml_self_canonical', 20 );

function custom_wpml_self_canonical( $canonical ) {

	// Only affect frontend singular content.
	if ( is_admin() || ! is_singular() ) {
		return $canonical;
	}

	// Return the current page's own URL as the canonical.
	return get_permalink();

}
				
			

The Results

The Results

The custom solution immediately resolved the canonical issue across the multilingual website.

Outcomes

  • Correct self-referencing canonical URLs for every translated page
  • Improved multilingual SEO implementation
  • Eliminated the need to manually update thousands of translated pages
  • Maintained WPML duplicate synchronization with parent pages
  • Fully compatible with Yoast SEO
  • Scalable solution for future multilingual content