Salta la navigazione

Open

Reported for: WPML SEO 2.1.0

Topic Tags: Compatibility

Overview of the issue

When using Different domains per language for your URL format, the sitemap doesn’t display the categories or product categories per language. Instead, it displays content from all your languages.

Workaround

Make a full backup of your site before proceeding:

  1. Add the following code to the theme’s functions.php file:
    /* 
    * WPML Workaround for compsupp-6571
    */
    add_filter('rank_math/sitemap/entry', 'wpml_compsupp6571_remove_sitemap_entry_from_different_domain', 10, 3);
    
    function wpml_compsupp6571_remove_sitemap_entry_from_different_domain ( $url, $type, $object ) {
    
    	if (! class_exists('SitePress') || apply_filters( 'wpml_setting', false, 'language_negotiation_type' ) != 2 ) {
    		return $url;
    	}	
    
    	$current_language = apply_filters( 'wpml_current_language', NULL );
    
    	if ($type == 'post') {		
    		$post_language_details = apply_filters( 'wpml_post_language_details', NULL, $object->ID ) ;
    		
    		if ( isset($post_language_details['language_code']) && $post_language_details['language_code'] != $current_language) {
    			return false;
    		}		
    	}
    		
    	elseif ($type == 'term') {
    		$args = array('element_id' => $object->term_taxonomy_id, 'element_type' => $object->taxonomy );
    		$term_language_details = apply_filters( 'wpml_element_language_details', NULL, $args  ) ;
    		
    		if (isset($term_language_details->language_code) && $term_language_details->language_code != $current_language) {
    			return false;
    		}		
    	}
    
    	return $url;
    }
    
  2. Go to Rank MathSitemap settings.
  3. Modify the Links Per Sitemap option and save the changes.
  4. Go to SettingsPermalinks and save. This will regenerate your permalinks.
  5. Check the sitemap. Each domain should display only content related to the current language.

4 risposte a “Rank Math SEO - Categories and product categories URLs aren't filtered by language on the sitemap”

Lasciare una risposta

Ti preghiamo di rimanere in tema e di essere rispettoso nei confronti degli altri. Se hai bisogno di aiuto per questioni non correlate a questo post, utilizza il nostro Forum di supporto per avviare una chat o inviare un ticket.

Potete usare questi tag:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>