WPML

问题概述

当使用 Product Filters for WooCommerce 的“Filter products by attribute”小工具,并将显示选项设置为“Dropdown”时,前端的属性标签未被翻译(例如,“Select Color”)。

临时解决方法

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

  • 将以下代码添加到您主题的 functions.php 文件中。
    PHP
    /**
     * Force the translation of product attribute labels on the frontend.
     */
    add_action( 'after_setup_theme', function() {
        if ( ! is_admin() && ! wpml_is_ajax() && function_exists( 'WPMLContainermake' ) ) {
            $wcStrings = WPMLContainermake( WCML_WC_Strings::class );
    
            if ( $wcStrings ) {
                add_filter( 'woocommerce_attribute_taxonomies', [ $wcStrings, 'translate_attribute_taxonomies_labels' ] );
            }
        }
    } );

所有已知问题

需要有关此问题的帮助?

提出支持问题,我们将与您一起调查。