Đổi thẻ H5 trong UX Product Categories giúp SEO tốt hơn
Có nhiều cách để thay đổi thẻ h5 trong UX Product Categories, nhưng theo tôi, cách sử dụng hàm dưới đây là tối ưu nhất. Lý do là nó xử lý trực tiếp trước khi hiển thị, giúp công cụ tìm kiếm nhận diện đúng cấu trúc mà không bị ảnh hưởng. Ngược lại, nếu dùng script để chỉnh sửa khi DOM đã tải xong, dù giao diện và trải nghiệm người dùng không thay đổi, nhưng robot tìm kiếm vẫn ghi nhận thẻ gốc. Đây là kinh nghiệm SEO mà tôi đã tích lũy được
English: There are many ways to modify the h5 tag in UX Product Categories, but in my opinion, using the function below is the most optimal approach. The reason is that it processes the change before rendering, ensuring that search engines recognize the correct structure without any impact. On the other hand, if you use a script to modify the tag after the DOM has loaded, the display and user experience remain unaffected, but search engine bots will still recognize the original tag. This is an SEO insight I have learned from experience.
function nguyenlan_ux_product_categories($output, $tag, $attr, $m) { if ($tag === 'ux_product_categories') { $output = str_replace('<h5', '<div', $output); $output = str_replace('</h5>', '</div>', $output); } return $output; } add_filter('do_shortcode_tag', 'nguyenlan_ux_product_categories', 10, 4);