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 9 / 12 — 105 bài viết
Tạo danh sách bài viết liên quan
<?php $post_id = get_the_ID(); $related_query = new WP_Query(array( 'post_type' => 'post', 'category__in' => wp_get_post_categories( $post_id ), 'post__not_in' => array( $post_id ), 'posts_per_page' => 8 )); ?> <?php if ($related_query->have_posts()) { ?> <div class="related-posts-grid"> <h2>Bài viết liên quan</h2> <?php while ($related_query->have_posts()) { ?> <?php $related_query->the_post(); ?> <div class="grid-item"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('post-thumb-small'); ?> </a> […]
Hướng dẫn lấy id chuyên mục hiện tại trong trang taxonomy
Cách lấy ID của chuyên mục bài viết hoặc ID của chuyên mục Custom Post Type Để lấy ID của chuyên mục các bạn hãy làm như sau. Trong trang chuyên mục bạn dán đoạn mã: <?php $current_term = get_queried_object(); $current_term_id = $current_term->term_id; ?> Kết quả trả về của hàm get_queried_object(); trong trang chuyên mục sẽ tương tự […]
Tạo thêm trường comment
https://www.smashingmagazine.com/2012/05/adding-custom-fields-in-wordpress-comment-form/
Hộp tìm kiếm liên kết trang web
Cách hiển thị hộp tìm kiếm trên Google giống ảnh bên dưới Bài viết chi tiết trên Google: https://developers.google.com/search/docs/data-types/sitelinks-searchbox?hl=vi
Những extention nên cài khi sử dụng Sublime Text
PACKAGE CONTROL EMMET DOCBLOCKR ALIGNMENT – ( CTRL + ALT + A)
Chuyển ảnh khi rê chuột vào sản phẩm trong woocommerce
add_action( 'woocommerce_before_shop_loop_item_title', 'add_on_hover_shop_loop_image' ) ; function add_on_hover_shop_loop_image() { $image_id = wc_get_product()->get_gallery_image_ids()[1] ; if ( $image_id ) { echo wp_get_attachment_image( $image_id ) ; } else { //assuming not all products have galleries set echo wp_get_attachment_image( wc_get_product()->get_image_id() ) ; } } /* CUSTOM ON-HOVER IMAGE */ .woocommerce ul.products li.product a img { /* FORMAT ALL IMAGES TO […]
Hướng dẫn sử dụng plugin WP All Import XML / CSV để nhập bài viết
Tóm tắt quá trình thực hiện gồm 2 bước chính: B1/ Xuất bản các bài viết ở website cũ ra file csv B2/ Nhập các bài biết ở website cũ sang website mới B1/ Xuất bản các bài viết ở website cũ ra file csv Cài plugin WP All Export Pro Cấu hình export post type […]
Hướng dẫn cấu hình chuyển hướng tên miền khác thư mục khác tên miền
Giả sử website mới ( http://newdomain.com ) có thư mục: Tin tức công nghê (tin-cong-nghe), Website cũ có thư mục: Tin tức (tin-tuc), Bây giờ ta muốn chuyển tất cả các bài viết trong chuyên mục Tin tức website cũ sang thư mục tin công nghệ của website mới ta làm các bước như sau: […]
Zip tất cả các file trong cùng thư mục
function tm_zip_all_barcode(){ $upload_dir = wp_upload_dir(); // Get real path for our folder $rootPath = $upload_dir['basedir'].'/barcode'; // Initialize archive object $zip = new ZipArchive(); $zip->open($upload_dir['basedir'].'/barcode.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); // Create recursive directory iterator /** @var SplFileInfo[] $files */ $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { // Skip directories […]