January 27, 2020
WPML: Fix Duplicate Hreflang Tags
Paste this into your theme’s functions.php file to prevent from Hreflang tags to appear on the same current language and fix duplicates.
add_filter('wpml_hreflangs', 'wpml_fix_duplicate_hreflangs', 10, 1); function wpml_fix_duplicate_hreflangs($hreflang_items){ foreach ($hreflang_items as $key => $item) { if (substr($key,0,2)==ICL_LANGUAGE_CODE) { unset($hreflang_items[$key]); } } return $hreflang_items; }