Tổng quan về sự cố
Khi sử dụng widget “Filter products by attribute” từ Product Filters for WooCommerce và thiết lập tùy chọn hiển thị thành “Dropdown”, nhãn thuộc tính không được dịch trên frontend (ví dụ: “Select Color”).
Giải pháp tạm thời
Vui lòng đảm bảo bạn có bản sao lưu toàn bộ trang web trước khi tiếp tục.
- Thêm mã sau vào tệp functions.php của giao diện.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' ] ); } } } );