Hello,
Chúng tôi xin lỗi vì vấn đề bạn đang gặp phải. Để xóa "Sản phẩm" trong cấu trúc Breadcrumb, bạn có thể sử dụng một đoạn mã PHP để thay đổi hoặc xóa các mục Breadcrumb. Dưới đây là cách thực hiện:
add_filter('rank_math/frontend/breadcrumb/items', function ($crumbs, $class) {
$key = array_search('Sản phẩm', array_column($crumbs, '0'), true);
if (isset($key)) {
unset($crumbs[$key]);
$crumbs = array_values($crumbs);
}
return $crumbs;
}, 10, 2);
Đoạn mã này sẽ tìm kiếm và xóa mục "Sản phẩm" khỏi cấu trúc Breadcrumb của bạn. Bạn có thể thêm đoạn mã này vào file functions.php của theme đang sử dụng.
Nếu bạn cần thêm hỗ trợ hoặc có câu hỏi khác, hãy trả lời lại ticket này và một nhân viên hỗ trợ từ đội ngũ Rank Math sẽ giúp bạn. Cảm ơn bạn đã mở ticket!
Sources:
How to Make Your Theme Rank Math Compatible » Rank Math
How to Make Your Theme Rank Math Compatible » Rank Math
Tôi có nên chèn trực tiếp chúng vào funtion.php. Và việc loại bỏ chúng có ảnh hưởng đến SEO không?
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
In this case, you can try this filter to remove the 2nd crumbs or “Products” from the breadcrumbs of your single product pages:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
if( is_product()) {
unset($crumbs[1]);
$crumbs[1] = [
$category->name,
site_url( $category->slug ),
'hide_in_schema' => false,
];
return $crumbs;
}
return $crumbs;
}, 10, 2);
Here’s a guide on how to add the code to your site:
https://rankmath.com/kb/filters-hooks-api-developer/
Looking forward to helping you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.