Code đếm view bài viết qua post meta không bị lưu cache
Code function trong childthem flatsome //dem view function update_post_view_log($post_id) { if (!is_numeric($post_id)) return; $views = get_post_meta($post_id, ‘_post_views’, true); $views =…
Xoá revision cũ và giảm revision khi viết bài
Xoá revision cũ, dùng code 1 lần, xoá đi sau khi dùng function delete_old_revisions() { global $wpdb; $wpdb->query(“DELETE FROM $wpdb->posts…
Viết hoa chữ cái đầu ở tiêu đề bằng script
<script> document.addEventListener(“DOMContentLoaded”, function() { var productTitles = document.querySelectorAll(‘.trchu h5’); productTitles.forEach(function(link) { // Viết hoa từng từ link.textContent = link.textContent.split(‘ ‘).map(function(word)…
Thêm thẻ mô tả tự động cho bài viết wordpress
function add_auto_meta_description() { if (is_single()) { // Chỉ áp dụng cho bài viết (post) global $post; if ($post) { $content…
Tự động lấy alt của ảnh trong media nếu ảnh bị lỗi do bị plugin nén ảnh
function add_missing_alt_from_media($content) { global $post; preg_match_all(‘/<img(.*?)src=”([^”]+)”(.*?)>/’, $content, $matches); if (!empty($matches[0])) { foreach ($matches[0] as $index => $img_tag) { if (strpos($img_tag,…
Thêm alt cho toàn bộ ảnh wordpress
// Chuyển tiêu đề tiếng Việt có dấu sang không dấu function remove_vietnamese_accents($str) { if (class_exists(‘Transliterator’)) { $transliterator = Transliterator::create(‘NFD;…
Hướng dẫn cách Active Office bằng lệnh CMD không cần phần mềm
Sau khi đã thực hiện và chuẩn bị sẵn sàng theo các yêu cầu ở trên, bạn có thể tiến…
Lazyload ảnh giảm thời gian tải trang
//lazy load function add_lazy_loading_to_images($content) { return str_replace(‘<img’, ‘<img loading=”lazy”‘, $content); } add_filter(‘the_content’, ‘add_lazy_loading_to_images’); function modify_image_attributes($content) { $content = preg_replace(‘/<img(.*?)src=/’, ‘<img$1data-src=’,…
Kích hoạt key flatsome 2024
Bước 1: Tìm và mở function trong child theme Bước 2: Copy đoạn code dưới đây update_option( ‘flatsome_wup_purchase_code’, ’50b6b124-b068-4b95-bb77-ec94d74f0300′ );…
Thêm trường tuỳ chỉnh sản phẩm hiển thị ra trang chủ wordpress
Bước 1: Cài plugin ACF để tạo trường tuỳ chỉnh Bước 2: Tìm và mở file /wp-content/themes/flatsome/inc/shortcodes/ux_products.php Bước 3: Chọn…







