WPML

问题概述

对于插入到 WooCommerce 产品简短说明中的图像,使用WPML Media Translation进行的图像翻译可能无法按预期工作。您可能会发现,尽管翻译了图像,但它并未出现在产品简短说明的翻译版本中。

临时解决方法

此问题已在 WPML 4.7.2 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。

在继续操作之前,请确保对您的站点进行完整备份。

  • 打开 …/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php 文件。
  • 找到第 146 行。
  • 替换:
    if ( $post_content_filtered !== $post->post_content ) {
    	$this->wpdb->update(
    		$this->wpdb->posts,
    		array( 'post_content' => $post_content_filtered ),
    		array( 'ID' => $post->ID ),
    		array( '%s' ),
    		array( '%d' )
    	);
    }
  • 替换为:
    if ( $post_content_filtered !== $post->post_content ) {
    	$this->wpdb->update(
    		$this->wpdb->posts,
    		array( 'post_content' => $post_content_filtered ),
    		array( 'ID' => $post->ID ),
    		array( '%s' ),
    		array( '%d' )
    	);
    }
    
    $post_excerpt_filtered = $this->images_updater->replace_images_with_translations(
    	$post->post_excerpt,
    	$post_element->get_language_code(),
    	$post_element->get_source_language_code()
    );
    
    if ( $post_excerpt_filtered !== $post->post_excerpt ) {
    	$this->wpdb->update(
    		$this->wpdb->posts,
    		array( 'post_excerpt' => $post_excerpt_filtered ),
    		array( 'ID' => $post->ID ),
    		array( '%s' ),
    		array( '%d' )
    	);
    }

所有已知问题

仍然遇到此问题?

如果更新无法解决问题,请提出支持问题,我们将与您一起排查。