Overview of the Issue
If you are using the Elementor loop template (opens in a new tab) feature, buttons aren’t translated on the front-end even if they are available for translation in the Advanced Translation Editor.
Workaround
This issue is fixed in WPML 4.6.4. Updating solves it on your site, so you only need this workaround if you can’t update yet.
Please be sure of making a full backup of your site before proceeding.
- Open the /wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/class-wpml-elementor-translate-ids.php file.
- Look for line 108.
- Replace the
WPML_Elementor_Translate_IDs::translate_global_widget_ids()method:PHPpublic function translate_global_widget_ids( $data_array, $post_id ) { foreach ( $data_array as &$data ) { if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) { if ( 'global' === $data['widgetType'] ) { $data['templateID'] = $this->translate_id( $data['templateID'] ); } elseif ( 'template' === $data['widgetType'] ) { $data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] ); } } $data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id ); } return $data_array; }
With:
PHPpublic function translate_global_widget_ids( $data_array, $post_id ) { foreach ( $data_array as &$data ) { if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) { if ( 'global' === $data['widgetType'] ) { $data['templateID'] = $this->translate_id( $data['templateID'] ); } elseif ( 'template' === $data['widgetType'] || 'loop-grid' === $data['widgetType'] || 'loop-carousel' === $data['widgetType']) { $data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] ); } } $data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id ); } return $data_array; }
- Translate the Elementor loop template in WPMLTranslation Management.