Function PHP xóa “Category Archives:” theme Flatsome không dùng CSS/JS

Function PHP này sẽ không làm ảnh hưởng tốc độ như là JS hoặc CSS khi xóa “Category Archives:” khỏi title category flatsome.

Copy code cách 1 hoặc 2 đều được, chèn vào file functions.php ở child theme Flatsome nhé!

 

Cách 1:

function custom_flatsome_category_title($translated_text, $text, $domain) {
if (is_category() && $domain === 'flatsome' && preg_match('/:\s*%s$/', $text)) {
return '%s'; // Loại bỏ prefix, giữ %s cho phần tên danh mục
}
return $translated_text;
}
add_filter('gettext', 'custom_flatsome_category_title', 20, 3);

 

Cách 2:

function custom_flatsome_remove_archive_prefix($translated_text, $text, $domain) {
    if ($domain !== 'flatsome') {
        return $translated_text;
    }


    if (is_category() && strpos($text, '%s') !== false) {
        $pos = strpos($text, '%s');
        if ($pos !== false) {
            $translated_text = substr($text, $pos);
        }
    }


    return $translated_text;
}
add_filter('gettext', 'custom_flatsome_remove_archive_prefix', 20, 3);
add_filter('gettext_with_context', 'custom_flatsome_remove_archive_prefix', 20, 3); // Hỗ trợ gettext_with_context nếu theme dùng

 

Bạn Cần Tư Vấn Về Thiết Kế & Vận Hành Website ?
Để lại thông tin liên hệ tại đây
×
Tạo & tải báo giá tự động

hoặc gửi mail cho chúng tôi

Họ & Tên Em có thể xưng hô như thế nào ạ?
Anh/Chị đang quan tâm dịch vụ nào?
Số điện thoại: Anh/Chị muốn em liên hệ lại lúc mấy giờ?
KÊNH HỖ TRỢ
🌸