- ステータス
- 解決済み
- 報告対象
- WPML Multilingual & Multicurrency for WooCommerce 5.2.0
- 解決されたバージョン
- WCML 5.3.0
- トピックタグ
- Compatibility
問題の概要
すべてのアーカイブページに表示するためにDiviテンプレートを作成し、テーマ内にtaxonomy-product_cat.phpファイルも存在する場合、競合が発生します。具体的には、Diviテンプレートはデフォルト言語でのみ表示されます。言語を切り替えるたびに、Diviテンプレートの代わりにtaxonomy-product_cat.phpファイルのテンプレートが表示されます。
回避策
続行する前に、必ずサイトの完全なバックアップを取得してください。
- テーマのfunctions.phpファイルを開きます。
- 次のコードを追加します。
add_filter('template_include', function ($template){ if (function_exists('wc_locate_template') && strpos($template, 'Divi/includes/builder') !== false && !file_exists(wc_locate_template(basename($template)))) { global $woocommerce_wpml; remove_filter( 'template_include', [ $woocommerce_wpml->store, 'template_loader' ], 100 ); } return $template; }, 99);
注意
この問題は、Elementorテンプレートでも発生する可能性があります。その場合は、代わりに次のスニペットを使用する必要があります。
add_filter('template_include', function ($template){
if (function_exists('wc_locate_template') && strpos($template, 'elementor') !== false && !file_exists(wc_locate_template(basename($template)))) {
global $woocommerce_wpml;
remove_filter( 'template_include', [ $woocommerce_wpml->store, 'template_loader' ], 100 );
}
return $template;
}, 12);