סקירת התקלה
בעת שימוש בווידג’ט Image Carousel של Elementor עם WPML, כיתובים מתורגמים לתמונות אינם מוצגים בחזית האתר, גם כאשר הכיתובים מתורגמים בספריית המדיה והעמוד מתורגם.
פתרון עוקף
בעיה זו תוקנה ב־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'] );
}
}