- 状态
- 已解决
- 报告针对
- WPML Multilingual & Multicurrency for WooCommerce 5.2.0
- 解决于
- WCML 5.3.0
- 主题标签
- Compatibility
问题概述
如果您创建了一个用于在所有存档页面上显示的 Divi 模板,并且您的主题中还有一个 taxonomy-product_cat.php 文件,就会出现冲突。具体来说,您的 Divi 模板将仅在默认语言中显示。每当您切换语言时,它将显示 taxonomy-product_cat.php 文件中的模板,而不是 Divi 模板。
临时解决方法
在继续操作之前,请确保对您的站点进行完整备份。
- 打开主题的 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);