WPML

Tổng quan về sự cố

Trong giao diện Bricks, khi một điều kiện của template được thiết lập để chỉ hiển thị cho các thuật ngữ cụ thể (ví dụ: một chuyên mục cụ thể), điều kiện này không được áp dụng chính xác trong các template đã dịch.

Giải pháp tạm thời

Sự cố này đã được khắc phục trong Bricks 2.0. Việc cập nhật giải quyết vấn đề này trên trang web của bạn, vì vậy bạn chỉ cần giải pháp tạm thời này nếu chưa thể cập nhật.

Vui lòng đảm bảo đã sao lưu toàn bộ trang web của bạn trước khi tiếp tục.

Phần I

  • Truy cập WPMLCài đặtTrường tùy chỉnh.
  • Tìm trường _bricks_template_settings.
  • Đặt thành Sao chép

Phần II

  • Mở tệp functions.php của giao diện.
  • Thêm mã sau:
    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;
    }

Tất cả lỗi đã ghi nhận

Vẫn gặp sự cố này?

Nếu việc cập nhật không khắc phục được, hãy đặt một câu hỏi hỗ trợ và chúng tôi sẽ cùng bạn xem xét.