Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.5.14

Resolved in: WPML 4.6.4

Topic Tags: Compatibility

Overview of the issue

If you are using the Elementor loop template feature, buttons aren’t translated on the front-end even if they are available for translation in the Advanced Translation Editor.

Workaround

Please be sure of making a full backup of your site before proceeding.

  1. Open the /wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/class-wpml-elementor-translate-ids.php file.
  2. Look for line 108.
  3. Replace the WPML_Elementor_Translate_IDs::translate_global_widget_ids() method:
    public 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:

    public 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;
        }
    
  4. Translate the Elementor loop template in WPMLTranslation Management.

22 所有回复 给 “Elementor Pro - Elementor loop template button does not translate”

  1. it seems like loop items are having issues

    The button is part of the loop item and doesn’t get translated.

    the loop items do not have template ids and get skipped over because they are actually linked to the loop item id

    The id im having issues with is 187bf51

    https://gc.tdgrepo.com/es/?s=jaws

    I got the new code but it doesnt work…I added some var dumps to track the issue…any help is appreciated.

    public function translate_global_widget_ids( $data_array, $post_id ) {
    foreach ( $data_array as &$data ) {
    if(is_search()){
    echo ‘ Type: ‘ . $data[‘elType’] . ”;
    if(isset( $data[‘templateID’])){
    echo ‘ Template ID ‘ . $data[‘templateID’] . ”;
    } else {
    echo ”;var_dump($data);echo ”;
    }
    if(isset( $data[‘id’])){echo ‘ ID ‘ . $data[‘id’] . ”;}
    }

    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;
    }

    • I’m glad to know that it worked and you can continue translating your site. 🙂
      Yes, it will be include in one of our next releases very soon. We will keep this erratum updated.
      Regards

  2. Hi guys,

    I had the bug again in a new website and remembered this.
    Would be nice you push this in the new version ? Is it plan ?

    Thanks

    Johann

    • Hello Johann,
      I’m glad it helped. Yes, this fix is already in our devs roadmap.
      We will keep this erratum updated once we release it.
      Regards

  3. Hi guys. I’ve tried to use this fix and It broke my site… Might have done something wrong.
    Can you check my code and tell me what to fix? or send me a fresh one to override the one I modified?

    • Hello Omer,
      Could you please open a chat in our support and add this erratum link? In that way, one of our specialists can check your website and verify why this code is broking your website.
      Thank you for your help.

  4. Hello everyone,
    This should be solved with WPML 4.6.4. Please don’t hesitate to make a full backup before updating your websites.
    Cheers!