如何使WordPress视图计数器计数1个视图10个视图

时间:2018-02-11 05:19:43

标签: javascript php wordpress

我有WordPress视图计数器的代码

<?php
// function to display number of posts.
function getPostViews($postID){
    $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 View";
    }
    return $count.' Views';
}

// function to count views.
function setPostViews($postID) {
    $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');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}

它有1个观察者= 1个视图 我想让它成为1个观众= 10个观点

我该怎么做?

1 个答案:

答案 0 :(得分:0)

$count++;更改为$count = $count + 10;

这不会夸大你的页数吗?