- 상태
- 해결됨
- 보고된 제품
- WPML SEO 2.1.0
- 해결된 버전
- 2.2.0
- 관련 플러그인/테마
- Rank Math SEO
- 주제 태그
- Compatibility
문제 개요
Rank Math SEO 플러그인을 사용할 때, 기본 언어의 상품 또는 글에 설정된 기본 카테고리가 번역에 동기화되지 않습니다. rank_math_primary_product_cat 사용자 정의 필드를 복사로 설정하더라도 이 문제는 계속 발생합니다.
임시 해결 방법
진행하기 전에 사이트의 전체 백업을 생성했는지 확인하세요.
- 테마의 functions.php 파일을 여세요.
- 다음 코드를 추가하세요:
// compsupp-6580: sync primary term and primary product terms for Rank Math add_filter('get_post_metadata', 'compsupp6580_filter_the_post_metadata', 20, 4); function compsupp6580_filter_the_post_metadata($value, $postId, $key, $single) { $meta_keys_mapping = array( 'rank_math_primary_category' => 'category', 'rank_math_primary_product_cat' => 'product_cat', ); if (in_array($key, array_keys($meta_keys_mapping), true)) { remove_filter('get_post_metadata', 'compsupp6580_filter_the_post_metadata', 20); $value = get_post_meta($postId, $key, true); add_filter('get_post_metadata', 'compsupp6580_filter_the_post_metadata', 20, 4); $args = [ 'element_id' => $postId, 'element_type' => get_post_type($postId), ]; $language = apply_filters('wpml_element_language_code', false, $args); $value = apply_filters('wpml_object_id', $value, $meta_keys_mapping[$key], true, $language); if (!$single) { $value = [$value]; } } return $value; }