דלג על ניווט

Open

Topic Tags: Compatibility

Overview of the issue

When using the Elementor Image Carousel Widget with WPML, translated captions for images do not display on the frontend, even when captions are translated in the Media Library and the page is translated.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following snippet:
  • // 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'] );
        }
    }
    
  • Remember to clear the Elementor cache

השאר מענה

אנא הישארו בנושא והיו מכבדים לאחרים. אם אתה צריך עזרה בבעיות שאינן קשורות לפוסט הזה, השתמש בפורום התמיכה שלנו כדי להתחיל צ'אט או לשלוח כרטיס.

תוכל להשתמש בתגים הבאים:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>