Blog cá nhân
Bài viết mới nhất
Chia sẻ kinh nghiệm thực tế về WordPress, lập trình và phát triển web.
Trang 2 / 12 — 111 bài viết

Hướng dẫn chuyển ảnh về định dạng Webp hay AVIF
Bạn nên cài đặt bộ plugin Performance Lab và trong đó có 1 plugin chuyển đổi image thành Webp hay Avif plugin đó có tên là: Modern Image Formats khi active plugin thì bạn vào phần: Settings > Media, tại mục Image out format: bạn chọn WebP or AVIF Tuy nhiên khi dùng plugin yoatSEO thì phần […]

Xử lý change status order Woocommerce khi refund từ Paypal
1. Webhook của PayPal cho Refund PayPal cung cấp webhook sự kiện “PAYMENT.SALE.REFUNDED”, bạn có thể đăng ký webhook này để nhận thông báo khi có refund xảy ra. 2. Cấu hình Webhook trong PayPal Truy cập PayPal Developer Dashboard: https://developer.paypal.com/ Chọn ứng dụng của bạn trong My Apps & Credentials. Trong phần Webhook, thêm […]

Hướng dẫn build lại ảnh hoặc media tải lên trong WordPress
Yêu cầu: tôi muốn sử dụng dịch vụ lưu trữ ở Amazon (S3) tuy nhiên website của tôi đã có hình ảnh tải lên media trước, vậy bây giờ làm sao tôi đưa những ảnh này lên S3 lại Giải pháp: Sử dụng plugin: Force Regenerate Thumbnails Plugin này có chứ năng tự động build lại […]

Update post meta ACF sử dụng Rest API WordPresss
Bước 1: Tạo Application Passwords Đối với WordPress phiên bản < 5.6 thì bạn cần phải cài đặt plugin Application Passwords, còn phiên bản >= 5.6 thì bạn không cần phải cài đặt plugin Bạn đăng nhập vào website, vào chỉnh sửa profile user, tại phần mật khẩu ứng dụng Bạn đặt tên mật khẩu ứng […]

Jquery ngăn không cho ô input type number nhập ký tự không hợp lệ
Giả sử ta có input có ô input như sau <input type=”number” class=”input-text qty text” name=”qty” value=”9″ min=”1″ max=”9″ step=”1″> jQuery(document).ready(function($) { // Ngăn không cho nhập ký tự không hợp lệ $(document).on(‘keydown’, ‘.qty’, function(e) { const allowedKeys = [8, 9, 27, 13, 46, 37, 38, 39, 40]; // Backspace, Tab, Escape, Enter, Delete, Arrow […]

Hướng dẫn làm phần compare products trong Woocommerce
Bước 1: Trong PHP <?php // Thêm extra fields class Extend_Attribute_Product extends WC_Product_Simple { public $fields; // Define new attribute, using for compare product } // 1. Thêm Nút So Sánh vào Sản Phẩm add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_custom_add_quick_cta’, 4 ); function woocommerce_custom_add_quick_cta(){ $product_id = get_the_ID(); $compare_products = isset($_SESSION[‘compare_products’]) ? $_SESSION[‘compare_products’] : []; $wishlist = isset($_COOKIE[‘wishlist’]) ? […]

Loadmore product woocommerce infinity scroll
Bước 1: Register jquery <?php add_action(‘wp_enqueue_scripts’, ‘enqueue_infinite_scroll_scripts’); function enqueue_infinite_scroll_scripts(){ if ( !is_shop() && !is_product_taxonomy() ) { return; } global $wp_query; wp_enqueue_script( ‘infinite-scroll’, THEME_URL . ‘/assets/js/infinite-scroll.js’, [‘jquery’], ‘1.0’, true ); wp_localize_script(‘infinite-scroll’, ‘lmproduct_obj’, [ ‘ajax_url’ => admin_url(‘admin-ajax.php’), ‘query_vars’ => json_encode($wp_query->query_vars), ‘nonce’ => wp_create_nonce( ‘lmp_check_nonce’ ), ‘max_num_pages’ => $wp_query->max_num_pages, ]); } ?> trong file infinite-scroll.js thêm đoạn code […]

Các bước cài lamp (apache, mysql, php ) trên vps ubuntu

Add the Meta Box Upload Multiple Images and multiple metabox
Step 1: Add Meta Boxes for Each Field Step 2: Display Each Meta Box // Profile Image Meta Box function profile_image_box_callback($post) { $image_ids = get_post_meta($post->ID, ‘profile_image_gallery’, true); $image_ids = is_array($image_ids) ? $image_ids : []; wp_nonce_field(‘profile_image_box_nonce’, ‘profile_image_box_nonce_field’); ?> <div id=”profile-image-gallery-wrapper”> <ul class=”custom-images-list”> <?php foreach ($image_ids as $image_id) : ?> <li> <?php echo wp_get_attachment_image($image_id, ‘thumbnail’); ?> <a […]

Add the Meta Box Repeat
Add the Meta Box // Register the meta box function wp_custom_meta_box() { add_meta_box( ‘custom_meta_box’, // ID ‘Custom Meta Box’, // Title ‘wp_custom_meta_box_html’, // Callback function ‘post’, // Post type ‘normal’, // Context ‘high’ // Priority ); } add_action(‘add_meta_boxes’, ‘wp_custom_meta_box’); function wp_custom_meta_box_html($post) { wp_nonce_field(‘save_custom_meta_box’, ‘custom_meta_box_nonce’); // Get existing data if available $meta_data = get_post_meta($post->ID, ‘_custom_meta_box’, true); […]