Để thay đổi tên “Brands” thành “Thương hiệu” trong breadcrumb của WooCommerce, bạn có thể thử một trong các cách sau:
Thay đổi tên cho Brands ở Breadcrumb trong WooCommerce

1. Dùng filter để thay đổi breadcrumb
Chèn đoạn code này vào file functions.php của theme đang sử dụng:
1 2 3 4 5 6 7 8 | add_filter('woocommerce_get_breadcrumb', function($crumbs) { foreach ($crumbs as &$crumb) { if ($crumb[0] === 'Brands') { // Kiểm tra nếu breadcrumb là "Brands" $crumb[0] = 'Thương hiệu'; // Thay đổi thành "Thương hiệu" } } return $crumbs; }); |
Cách này mạnh hơn woocommerce_breadcrumb_defaults và có thể áp dụng với nhiều theme.
2. Ghi đè breadcrumb nếu dùng plugin tạo thương hiệu
Một số plugin WooCommerce quản lý Brands như Perfect WooCommerce Brands, YITH WooCommerce Brands Add-on có thể tạo breadcrumb riêng. Hãy kiểm tra xem bạn đang dùng plugin nào và thử thay đổi bằng filter:
Với Perfect WooCommerce Brands


Thêm vào functions.php:
1 2 3 | add_filter('perfect_brand_breadcrumb', function($breadcrumb) { return str_replace('Brands', 'Thương hiệu', $breadcrumb); }); |
Với YITH WooCommerce Brands Add-on
1 2 3 4 5 6 7 8 | add_filter('yith_wcbr_breadcrumbs_args', function($args) { foreach ($args['breadcrumb'] as &$crumb) { if ($crumb['text'] === 'Brands') { $crumb['text'] = 'Thương hiệu'; } } return $args; }); |
3. Ghi đè breadcrumb trong WooCommerce template
Nếu breadcrumb vẫn không thay đổi, bạn có thể ghi đè file template của WooCommerce.
Bước 1: Tạo thư mục trong theme nếu chưa có:
wp-content/themes/tên-theme/woocommerce/global/
Bước 2: Copy file breadcrumb.php từ WooCommerce:
wp-content/plugins/woocommerce/templates/global/breadcrumb.php
và dán vào thư mục:
wp-content/themes/tên-theme/woocommerce/global/breadcrumb.php
Bước 3: Mở file breadcrumb.php trong theme và tìm dòng chứa “Brands“, thay thành “Thương hiệu“.
4. Dùng JavaScript thay đổi breadcrumb trên giao diện
Nếu không thể sửa trong PHP, có thể dùng JavaScript:
1 2 3 4 5 6 7 8 | document.addEventListener("DOMContentLoaded", function() { let breadcrumbs = document.querySelectorAll(".woocommerce-breadcrumb a"); breadcrumbs.forEach(link => { if (link.innerText.includes("Brands")) { link.innerText = "Thương hiệu"; } }); }); |
Chèn đoạn này vào Customize > Additional CSS & JS hoặc footer.php của theme.
Kiểm tra cache
Nếu bạn đã thử sửa nhưng không thấy thay đổi, hãy kiểm tra:
- Xóa cache trình duyệt.
- Nếu dùng plugin cache (WP Rocket, LiteSpeed Cache, v.v.), hãy xóa cache.
- Nếu website có CDN (Cloudflare), hãy xóa cache trên Cloudflare.