Skip Navigation


Reported for: WPML SEO 2.0.1

Topic Tags: Multilingual SEO

Overview of the issue

If you are formatting your URLs to display language as a parameter in WPMLLanguages, you will notice that pages in secondary languages that are paginated will display an incorrect canonical link.


Please, make a full backup of your site before proceeding. Then, add the following code in your functions.php theme file:

    function wpmldp_filter_wpseo_canonical_lang_parameter_position( $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 ); 

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>