탐색 건너뛰기

Waiting for author

Reported for: WPML SEO 2.1.0

Topic Tags: Compatibility

Overview of the issue

When using SEOPress plugin with WPML, the product archive slugs are not correctly translated in the XML sitemaps generated by SEOPress.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/wp-content/plugins/wp-seopress/templates/sitemap/single.php file.
  • Look for line 41.
  • Replace:
    // WPML Workaround
    if (class_exists('SitePress')) {
    	if ( 2 != apply_filters( 'wpml_setting', false, 'language_negotiation_type' ) ) {
    		$original_language = apply_filters( 'wpml_current_language', NULL );
    		$language_list = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
    
    		if (!empty($language_list)) {
    			foreach ($language_list as $key => $language_infos ) {
    				if ($original_language != $language_infos['language_code']) {
    
    					// Switch Language
    					do_action( 'wpml_switch_language', $language_infos['language_code']);
    
    					$archive_links[] = htmlspecialchars(urldecode(user_trailingslashit(get_post_type_archive_link($path))));
    
    					// Restore language to the original
    					do_action( 'wpml_switch_language', $original_language);
    				}
    			}
    		}
    	}
    
  • With:
    // WPML Workaround for compsupp-7538 and compsupp-6419
    if ( class_exists('SitePress' )) {
    	if ( 2 != apply_filters( 'wpml_setting', false, 'language_negotiation_type' ) ) {
    		$original_language = apply_filters( 'wpml_current_language', NULL );
    		$language_list = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
    
    		if (!empty($language_list)) {
    			foreach ($language_list as $key => $language_infos ) {
    				if ($original_language != $language_infos['language_code']) {
    					// Switch Language
    					do_action( 'wpml_switch_language', $language_infos['language_code']);
    
    					if ( $path == 'product' && function_exists('wc_get_page_id') ) {
    						$shop_page_id = wc_get_page_id('shop');
    						$archive_links[] = 	htmlspecialchars(urldecode(user_trailingslashit(get_permalink($shop_page_id))));
    					} else {
    						$archive_links[] = htmlspecialchars(urldecode(user_trailingslashit(get_post_type_archive_link($path))));	
    					}
    
    					// Restore language to the original
    					do_action( 'wpml_switch_language', $original_language);
    				}
    			}
    		}
    	}
    }
    

답장을 남겨주세요

주제를 유지하고 다른 사람을 존중하십시오. 이 게시물과 관련 없는 문제에 대한 도움이 필요한 경우 지원 포럼을 사용하여 채팅을 시작하거나 티켓을 제출하십시오.

다음 태그를 사용할 수 있습니다.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>