문제 개요
WPML과 함께 Elementor 이미지 캐러셀 위젯을 사용할 때, 미디어 라이브러리에서 캡션이 번역되고 페이지가 번역된 경우에도 프런트엔드에 이미지의 번역된 캡션이 표시되지 않습니다.
임시 해결 방법
이 문제는 WPML Multilingual CMS 4.7.4에서 해결되었습니다. 업데이트하면 사이트에서 문제가 해결되므로, 아직 업데이트할 수 없는 경우에만 이 임시 해결 방법이 필요합니다.
진행하기 전에 전체 사이트 백업을 완료했는지 확인하세요.
- 테마의 functions.php 파일을 여세요.
- 다음 스니펫을 추가하세요.
// 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'] );
}
}