How to make Fake Views on Wordpress

I dont know how to code and sorry for my bad english, so i found a code here to make a random views on my post views using $count = rand(700,999); which make a random views for my post but the problem is everytime a user click a post views changes again and not update the meta data.

function ktz_setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
    $count = 1;
    delete_post_meta($postID, $count_key);
    add_post_meta($postID, $count_key, '0');
}else{
    $count++;
    $count = rand(700,999);
    update_post_meta($postID, $count_key, $count);
}
return $count; /* so you can show it */

What i want is everytime a user click a post the views add up not changes to 700 - 999..

please help i want to make a fake views for my site..

Topic views Wordpress

Category Web


Use something like this : (add it in your function.php) and load your site once. after it finish, deactivate the function. (don't forget to declare your $postID)

function my_update_posts() {
    $count_key = 'post_views_count';
    $args = array(
        'post_type' => 'post',
        'numberposts' => -1
    );
    $myposts = get_posts($args);
    foreach ($myposts as $mypost){
        $mypost->post_title = $mypost->post_title.'';
        $count = rand(700,999);
        update_post_meta($postID, $count_key, $count);
        wp_update_post( $mypost );
    }
}
add_action( 'wp_loaded', 'my_update_posts' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.