WPML
ステータス
解決済み
解決されたバージョン
WPML Multilingual CMS 4.7.4
関連するプラグイン/テーマ
Elementor
トピックタグ
Compatibility

問題の概要

WPMLでElementorの画像カルーセルウィジェットを使用する場合、メディアライブラリでキャプションが翻訳され、ページが翻訳されている場合でも、フロントエンドに翻訳された画像のキャプションが表示されません。

回避策

作業を進める前に、必ずサイトの完全なバックアップを取得してください。


  • テーマのfunctions.phpファイルを開きます。

  • 次のスニペットを追加します。
// WPML Workaround for compsupp-7726
add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7726_filter_imagecarousel_widget');

function wpml_compsupp7726_filter_imagecarousel_widget($element) {
	if ( 'image-carousel' !== $element->get_name() ) {
        return;
    }

    $settings = $element->get_settings();

    if ( isset( $settings['carousel'] ) && is_array( $settings['carousel'] ) ) {
        foreach ( $settings['carousel'] as $key => $value ) {      

            $post_type = get_post_type( $value['id'] );

			if ( ! $post_type ) {
				continue;
			}

			$value['id'] = apply_filters( 'wpml_object_id', $value['id'], $post_type, true );

			unset($settings['carousel'][$key]['id']);
			$settings['carousel'][$key]['id'] = $value['id'];
		}

        $element->set_settings( 'carousel', $settings['carousel'] );
    }
}

  • Elementorのキャッシュを忘れずにクリアしてください。
  • すべての既知の問題 →