lập trình mới hiển thị lượt xem bài viết wordpress
Thông tài năng mới cao chúng ta sẽ plugin đếm số lượt view, hiện nay sở hữu nhất khá là phổ biến plugin giúp 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ị thúc đẩy mới tốc độ. người mua copy đoạn lập trình mới 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' ); nê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 etặng nhất get_comments_number();?></span> </div> <div class="pt-view"> <span class="dashicons dashicons-visibility"></span> <span><?php echo getPostViews(get_the_ID());?></span> </div> </div> <?php chính
Nguyễn Thanh Tuấn (sieutocviet.com)
Từ nền tảng lập trình PHP, Python cùng 7 năm thực chiến trong quản lý website, tôi mang đến giải pháp SEO & marketing online tối ưu giúp doanh nghiệp tăng trưởng bền vững.