WPML
상태
개발자가 해결함
해결된 버전
Bricks 2.0
관련 플러그인/테마
Bricks
주제 태그
Compatibility

문제 개요

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

임시 해결 방법

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

1부


  • WPML > 설정 > 사용자 정의 필드로 이동하세요.

  • _bricks_template_settings 필드를 찾으세요.

  • 복사로 설정하세요

2부


  • 테마의 functions.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;
    }

알려진 모든 문제 →