Saltar navegación

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using the Image Slider widget from the ThemeRex Addons plugin in Elementor, translated images from WPML Media Translation do not display on translated pages. Instead, the same image from the default language is shown across all languages.

Workaround

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

  • Open the Open your theme’s functions.php file and add the following code
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    // WPML Workaround for compsupp-7754
    add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7754_trx_widget_slider_widget');
     
    function wpml_compsupp7754_trx_widget_slider_widget($element) {
        if ( 'trx_widget_slider' !== $element->get_name() ) {
            return;
        }
     
        $settings = $element->get_settings();
     
        if ( isset( $settings['slides'] ) && is_array( $settings['slides'] ) ) {
            foreach ( $settings['slides'] as $key => $value ) {  
                if ( is_array($value) && isset( $value['image']['id'] ) ) {
                    $post_type = get_post_type( $value['image']['id'] );     
                    if ( $post_type ) {
                        $translated_id = apply_filters( 'wpml_object_id', $value['image']['id'], $post_type, true );
                        $translated_url = wp_get_attachment_url($translated_id);
                        $settings['slides'][$key]['image']['id'] = $translated_id;
                        $settings['slides'][$key]['image']['url'] = $translated_url;
                    }
                }
                 
            }
     
            $element->set_settings( 'slides', $settings['slides'] );
        }
    }

Deje una respuesta

Por favor, mantente dentro del tema y sé respetuoso con los demás. Si necesitas ayuda con cuestiones no relacionadas con este post, utiliza nuestro Foro de soporte para iniciar un chat o enviar un ticket.

Puede utilizar estas etiquetas:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>