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 — 105 bài viết

How to

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’]) ? […]

25/12/2024·7 phút đọc
How to

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 […]

25/12/2024·2 phút đọc
Chưa được phân loại

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

04/10/2024·1 phút đọc
How to

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 […]

03/10/2024·3 phút đọc
How to

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); […]

03/10/2024·2 phút đọc
How toJavascript

Kỹ thuật debounce trong javascript – Trì hoãn nhập từ khóa trong ô input

HTML <div class=”seachbox”> <input type=”text” name=”seach-text” id=”seach-text”> </div> Javascript: function delay(callback, ms) { var timer = 0; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { callback.apply(context, args); }, ms || 0); }; } $(‘#seach-text’).keyup( delay(function (e) { console.log(‘Time elapsed!’, this.value); }, 500) );  

03/10/2024·1 phút đọc
How to

Thêm VS Code snippets

{ // Place your snippets for php here. Each snippet is defined under a snippet name and has a prefix, body and // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // $1, $2 for tab stops, $0 for the final […]

01/10/2024·2 phút đọc
Chưa được phân loại

Hướng dẫn setup docker trên local chạy WordPress

Đang cập nhật…

25/09/2024·1 phút đọc
Chưa được phân loại

Import database in docker

### Import database in docker ### -i mysql mysql -u[user] -p[password] -f database_name < ten-file-sql.sql vd: user: root, pass: 123456, db: abc_db, file_Db: db.sql => sudo docker exec -i mysql mysql -uroot -p123456 -f abc_db < db.sql  

24/09/2024·1 phút đọc