문제 개요
WPML과 함께 SEOPress를 사용할 때, “기본 언어를 대체 언어로 사용” 또는 “콘텐츠 복제” 방식을 사용하면 번역되지 않은 콘텐츠의 표준 URL이 기본 언어를 가리키지 않습니다. 이로 인해 중복 콘텐츠 문제가 발생할 수 있습니다.
임시 해결 방법
이 문제는 해결되었습니다. 최신 버전으로 업데이트하면 사이트에서 이 문제가 해결되므로, 아직 업데이트할 수 없는 경우에만 이 임시 해결 방법이 필요합니다.
진행하기 전에 전체 사이트 백업을 완료했는지 확인하세요.
- 열기: …/wp-content/plugins/wp-seopress/inc/functions/options-titles-metas.php
- 1022번째 줄을 찾으세요.
- 다음 코드를:
PHP
function seopress_titles_canonical_hook() { global $wp; $current_url = user_trailingslashit(home_url(add_query_arg([], $wp->request))); if (is_search()) { $seopress_titles_canonical = ''; } elseif (is_paged() && is_singular()) {//Paginated pages $seopress_titles_canonical = ''; } elseif (is_paged()) { $seopress_titles_canonical = ''; } elseif (is_singular()) { $seopress_titles_canonical = ''; } else { $seopress_titles_canonical = ''; } //Hook on post canonical URL - 'seopress_titles_canonical' if (has_filter('seopress_titles_canonical')) { $seopress_titles_canonical = apply_filters('seopress_titles_canonical', $seopress_titles_canonical); } echo $seopress_titles_canonical . "\n"; }
- 다음으로 교체하세요:
PHP
function seopress_titles_canonical_hook() { global $wp; $current_url = user_trailingslashit(home_url(add_query_arg([], $wp->request))); // WPML Workaround for compsupp-7703 if (class_exists('SitePress')) { $post_ID = get_the_ID(); $post_type = get_post_type( $post_ID ); $transl_status = apply_filters( 'wpml_element_translation_type', NULL, $post_ID, $post_type ); // If the post is not translated, switch to the default language if ($transl_status != 1) { $my_default_lang = apply_filters('wpml_default_language', NULL ); $my_current_lang = apply_filters( 'wpml_current_language', NULL ); do_action( 'wpml_switch_language', $my_default_lang ); } } if (is_search()) { $seopress_titles_canonical = ''; } elseif (is_paged() && is_singular()) {//Paginated pages $seopress_titles_canonical = ''; } elseif (is_paged()) { $seopress_titles_canonical = ''; } elseif (is_singular()) { $seopress_titles_canonical = ''; } else { $seopress_titles_canonical = ''; } // Then switch back to the current language if (class_exists('SitePress')) { if ($transl_status != 1) { do_action( 'wpml_switch_language', $my_current_lang ); } } //Hook on post canonical URL - 'seopress_titles_canonical' if (has_filter('seopress_titles_canonical')) { $seopress_titles_canonical = apply_filters('seopress_titles_canonical', $seopress_titles_canonical); } echo $seopress_titles_canonical . "\n"; }