WPML
סטטוס
נפתר על ידי המפתח
דווח עבור
WPML SEO 2.0.1

סקירה כללית של התקלה

זוהי בעיה כללית ב־Yoast SEO (לא ספציפית ל־WPML) והיא דווחה כאן.

אם אתה מגדיר את כתובות ה־URL שלך כך שיציגו את השפה כפרמטר ב־WPMLשפות, תבחין שעמודים בשפות משניות המחולקים לעמודים יציגו קישור קנוני שגוי.

פתרון עוקף

אנא בצע גיבוי מלא של האתר לפני שתמשיך. לאחר מכן, הוסף את הקוד הבא בקובץ ערכת העיצוב functions.php:

 
// define the wpseo_canonical callback 
function wpmldp_filter_wpseo_canonical_lang_parameter_position( $canonical ) { 
        // decode URL
        $canonical = urldecode($canonical);
	
	// get current language
	$my_current_lang = apply_filters( 'wpml_current_language', NULL );
	
	// define ?lang parameter
	$param = '?lang='.$my_current_lang;
	
	// check if current $canonical contains the parameter
	if(strpos($canonical, $param) !== false){
		
		// remove the parameter from URL
		$canonical = str_replace('/'.$param, "", $canonical);
		
		// add it again
		$canonical = $canonical.$param;
	}	
	
    return $canonical; 
}; 
         
// add the filter 
add_filter( 'wpseo_canonical', 'wpmldp_filter_wpseo_canonical_lang_parameter_position', 999 ); 

כל התקלות הידועות →