lập trình mới hiển thị lượt xem bài viết wordpress
Thông có thể chúng ta sẽ plugin đếm số lượt view, hiện nay nắm tới khá là nhiều plugin giúp tặng mới việc này, ở nội dung bài viết nhất này chúng ta sẽ tiêu dùng code nhằm tránh mới bị đẩy mạnh tốc độ. quý khách mới hàng copy đoạn code dưới đây và dán vào function nhéfunction setPostViews()$postID = get_the_ID();$count_key = 'post_views_count';$count = get_post_meta($postID, $count_key, true);if($count=='')$count = 0;delete_post_meta($postID, $count_key);add_post_meta($postID, $count_key, '0');hữu ích else$count++;update_post_meta($postID, $count_key, $count);xa
Sau đó chúng ta dùng hàm setPostViews(); dán nó vào bên trong tầm lặp của bài viết tại file single.php của theme bạn đang tiêu dùng.

function getPostViews()$postID = get_the_ID(); $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count=='')delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0"; chỉ return $count;

add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' ); function load_dashicons_front_end() wp_enqueue_style( 'dashicons' ); cần add_action('flatsome_blog_post_after','get_total_like'); function get_total_like();?> <div class="pt-view-cmt"> <div class="pt-cmt"> <span class="dashicons dashicons-admin-comments"></span> <span><?php echo get_comments_number();?></span> </div> <div class="pt-view"> <span class="dashicons dashicons-visibility"></span> <span><?php etặng mới getPostViews(get_the_ID());?></span> </div> </div> <?php chính
Diệp Toàn Phát (sieutocviet.vn)
Với hơn 5 năm kinh nghiệm thực chiến Python, PHP và 7 năm quản trị website, tôi chuyên tư vấn giải pháp SEO từ khóa, Digital Marketing tối ưu cho doanh nghiệp. Hiện là trưởng phòng kinh doanh tại Siêu Tốc Việt.