WPML

문제 개요

Bricks Theme에서 템플릿 조건이 특정 용어(예: 특정 카테고리)에만 표시되도록 설정된 경우, 번역된 템플릿에서 해당 조건이 올바르게 적용되지 않습니다.

임시 해결 방법

이 문제는 Bricks 2.0에서 해결되었습니다. 업데이트하면 사이트에서 문제가 해결되므로, 아직 업데이트할 수 없는 경우에만 이 임시 해결 방법이 필요합니다.

진행하기 전에 사이트의 전체 사이트 백업을 완료했는지 확인하세요.

1부

  • WPML설정사용자 정의 필드로 이동하세요.
  • _bricks_template_settings 필드를 찾으세요.
  • 복사로 설정하세요

2부

  • 테마의 functions.php 파일을 여세요.
  • 다음 코드를 추가하세요:
    PHP
    /**
     * WPML Workaround for compsupp-7667
     */
    add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
    function wpml_compsupp7667_bricks_translate_template_conditions($value, $post_id, $key, $single) {
        if ($key !== '_bricks_template_settings') {
            return $value;
        }
    
        // Remove filter temporarily to avoid infinite loop
        remove_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10);
    
        // Get all meta values
        $raw_values = get_post_meta($post_id, $key, false);
    
        // Add filter back
        add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
    
        // If we have no values, return the original
        if (empty($raw_values)) {
            return $value;
        }
    
        // Process the array structure
        foreach ($raw_values as &$settings) {
            if (is_array($settings) && isset($settings['templateConditions'])) {
                foreach ($settings['templateConditions'] as &$condition) {
                    if (!empty($condition['archiveTerms']) && is_array($condition['archiveTerms'])) {
                        foreach ($condition['archiveTerms'] as &$termString) {
                            if (strpos($termString, '::') !== false) {
                                list($taxonomy, $termId) = explode('::', $termString);
                                $translatedId = apply_filters('wpml_object_id', intval($termId), $taxonomy, true);
                                if ($translatedId) {
                                    $termString = $taxonomy . '::' . $translatedId;
                                }
                            }
                        }
                    }
                }
            }
        }
    
        return $raw_values;
    }

모든 알려진 문제

여전히 이 문제가 발생합니까?

업데이트해도 문제가 해결되지 않으면 지원 문의를 하세요. 함께 살펴보겠습니다.