Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Canonical and hreflang tag issues #70

Open
straube opened this issue Jan 16, 2020 · 2 comments
Open

Canonical and hreflang tag issues #70

straube opened this issue Jan 16, 2020 · 2 comments

Comments

@straube
Copy link
Owner

straube commented Jan 16, 2020

Issues reported on the plugin support forum (https://wordpress.org/support/topic/two-problems-25/):

  1. Plugin is adding wrong canonical link that is missing Trailing slash in post permalink at the end. – Yoast already take care of this part. And, I could fix this by disabling “Add canonical link” checkbox.

  2. Plugin is adding hreflang=”x-default even when my language settings is None.

@thegulshankumar
Copy link

Thanks for your concern.

@thegulshankumar
Copy link

@straube Hi

Bug: Wrong x-default

Suppose, English is the primary language. Spanish version is added via WPML.

<link rel="alternate" hreflang="en" href="https://example.com/about/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/acerca-de/" />

Problem
If I go to view-source:https://example.com/es/acerca-de/ when plugin active it print in head

<link rel="alternate" href="https://example.com/acerca-de/" hreflang="x-default" />

Expected
<link rel="alternate" href="https://example.com/about/" hreflang="x-default" />

Well, I am already able to add proper x-default tag with below snippet

/* ---------------------------------------------------------------------------
 * Set hreflang="x-default" with WPML
 * --------------------------------------------------------------------------- */
add_filter('wpml_alternate_hreflang', 'wps_head_hreflang_xdefault', 10, 2);
function wps_head_hreflang_xdefault($url, $lang_code) {
      
    if($lang_code == apply_filters('wpml_default_language', NULL )) {
          
        echo '<link rel="alternate" href="' . $url . '" hreflang="x-default" />'.PHP_EOL;
    }
      
    return $url;
}

Please make adding hreflang optional and fix it as well.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants