WPML
Trạng thái
Đã giải quyết
Đã giải quyết trong
WPML Multilingual CMS 4.7.4
Plugin/giao diện liên quan
Elementor
Thẻ chủ đề
Compatibility

Tổng quan về lỗi

Khi sử dụng widget Image Carousel của Elementor với WPML, các chú thích đã dịch của hình ảnh không hiển thị trên front-end, ngay cả khi các chú thích đã được dịch trong Thư viện phương tiện và trang đã được dịch.

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

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


  • Mở tệp functions.php trong giao diện của bạn.

  • Thêm đoạn mã sau:
// WPML Workaround for compsupp-7726
add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7726_filter_imagecarousel_widget');

function wpml_compsupp7726_filter_imagecarousel_widget($element) {
	if ( 'image-carousel' !== $element->get_name() ) {
        return;
    }

    $settings = $element->get_settings();

    if ( isset( $settings['carousel'] ) && is_array( $settings['carousel'] ) ) {
        foreach ( $settings['carousel'] as $key => $value ) {      

            $post_type = get_post_type( $value['id'] );

			if ( ! $post_type ) {
				continue;
			}

			$value['id'] = apply_filters( 'wpml_object_id', $value['id'], $post_type, true );

			unset($settings['carousel'][$key]['id']);
			$settings['carousel'][$key]['id'] = $value['id'];
		}

        $element->set_settings( 'carousel', $settings['carousel'] );
    }
}

  • Nhớ xóa cache của Elementor
  • Tất cả các lỗi đã ghi nhận →