Skip Navigation

Open

Overview of the issue

When using the uDesign theme and the uDesign Image Gallery Elementor’s widget, image captions are not being translated on the front end, even though the translations exist.

Workaround

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

  • Open your theme’s functions.php file.
    // WPML Workaround for compsupp-7754
    add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7754');
      
    function wpml_compsupp7754($element) {
        if ( 'udesign_widget_imagegallery' !== $element->get_name() ) {
            return;
        }
      
        $settings = $element->get_settings();
      
        if ( isset( $settings['images'] ) && is_array( $settings['images'] ) ) {
            foreach ( $settings['images'] as $key => $value ) {   
                if ( is_array($value) && isset( $value['id'] ) ) {
                    $post_type = get_post_type( $value['id']);      
                    if ( $post_type ) {
                        $translated_id = apply_filters( 'wpml_object_id', $value['id'], $post_type, true );
                        $settings['images'][$key]['id'] = $translated_id;
                    }
                }
                  
            }
      
            $element->set_settings( 'images', $settings['images'] );
        }
    }
            

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>