Bước 1 tạo 1 ux bloks như hình nội dung là quangcao-chiaseazz.com hoặc gì bạn muốn
bước 2 chèn code này vào fuction
function add_custom_popup() { ?> <div id="custom-popup" class="popup-overlay" style="display: none;"> <div class="popup-content"> <a href="#" id="popup-close" class="popup-close">×</a> <div class="popup-inner"> <?php echo do_shortcode('Block "quangcao" not found
'); ?> </div> </div> </div> <style> .popup-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); /* Nền đen với độ mờ */ display: none; z-index: 9999; } .popup-content { position: relative; margin: 10% auto; padding: 20px; background: #fff; border-radius: 5px; width: 50%; } .popup-close { position: absolute; top: 10px; right: 20px; text-decoration: none; font-size: 30px; color: #fff; /* Nút tắt có màu trắng */ background: rgba(0, 0, 0, 0.5); /* Nền bán trong suốt */ padding: 5px; border-radius: 50%; cursor: pointer; z-index: 10000; /* Đảm bảo nút tắt nằm trên nền */ } .popup-close:hover { background: rgba(0, 0, 0, 0.8); /* Nền tối hơn khi hover */ } @media (max-width: 768px) { .popup-content { width: 90%; } } </style> <script> document.addEventListener("DOMContentLoaded", function () { let lastClosed = localStorage.getItem("popupClosedTime"); let now = Date.now(); // Nếu popup đã đóng và chưa hết 3 phút, không hiển thị lại if (!lastClosed || now - lastClosed >= 180000) { setTimeout(function() { document.getElementById("custom-popup").style.display = "block"; }, 3000); // Hiển thị popup sau 3 giây } // Đóng popup khi click vào vùng ngoài popup (overlay) document.getElementById("custom-popup").addEventListener("click", function(e) { if (e.target === this) { document.getElementById("custom-popup").style.display = "none"; localStorage.setItem("popupClosedTime", Date.now()); } }); // Đóng popup khi click vào nút đóng document.getElementById("popup-close").addEventListener("click", function(e) { e.preventDefault(); document.getElementById("custom-popup").style.display = "none"; localStorage.setItem("popupClosedTime", Date.now()); }); }); </script> <?php } add_action('wp_footer', 'add_custom_popup');
và nhận thành quả
chúc bạn thành công