Recently, a client of the site owner found the site owner and consulted about WordPress 插件 WordPress post views cheating method! Talking about the reason, it's because he used his own website WPCOM Theme of JustnewscheatingWay, set up a new siteBrowseIncrease the quantity to attract customers to read!
Actually, the site owner doesn't really like this kind of approach, after all, such “watered-down” fake data is not good for the long-term survival of the website! However, the client keeps asking to persist, so I'll just help the client solve this problem and share the solution here, hoping that some small friends who need it can use it.
解决办法
First, we need to modify the files of the wp-postviews plugin, and we first need to add a filter to the post views counter to exclude certain post types. /wp-content/plugins/wp-postviews/wp-postviews.php Please provide the code on lines 119 and 120, and I'll translate it from Simplified Chinese to American English while following the critical rules.
update_post_meta( $id, 'views', $post_views + 1 );
do_action( 'postviews_increment_views', $post_views + 1 );
Please provide the Simplified Chinese text you'd like me to translate to American English. I'll make sure to follow the critical rules and terminology hints to produce the translated text.
update_post_meta( $id, 'views', ( $post_views + mt_rand(1, 50) ) );
do_action( 'postviews_increment_views', ( $post_views + mt_rand(1, 50) ) );
Where (1, 50) indicates that each time the article page is refreshed, the browser's view value will increase by a minimum of 1 and a maximum of 50, and friends can also set the minimum and maximum values according to their own needs! Translated text: Where (1, 50) indicates that each time the article page is refreshed, the browser's view value will increase by a minimum of 1 and a maximum of 50, and friends can also set the minimum and maximum values according to their own needs!
But then some friends asked, "What if our site uses article collection and publishing, and the article collection will not generate corresponding browsing numbers immediately after publishing, what to do?" Don't worry, we can add the following content before and after the previous code:
But then some friends asked, "What if our site uses article collection and publishing, and the article collection will not generate corresponding browsing numbers immediately after publishing, what to do?" Don't worry, we can add the following content before and after the previous code:
Note: The translation is in American English, and the original text is in Simplified Chinese.if($post_views<100){ update_post_meta( $id, 'views', ( $post_views + mt_rand(1000, 2000) ) );
do_action( 'postviews_increment_views', ( $post_views + mt_rand(1, 50) ) );
}else{
(原来119行和120行的代码内容)
}
完整代码为:
if($post_views<100){ update_post_meta( $id, 'views', ( $post_views + mt_rand(1000, 2000) ) );
do_action( 'postviews_increment_views', ( $post_views + mt_rand(1, 50) ) );
}else{
update_post_meta( $id, 'views', $post_views + 1 );
do_action( 'postviews_increment_views', $post_views + 1 );
}
When the browsing value is less than 100, a random browsing value between 1000 and 2000 will be added, and this will only happen once! Subsequent browsing values will be visited with a random value between 1 and 50.
Tutorial is very simple, although this browsing value is just self-deception, but it may also be a initial operating method! Hope it can help all the little friends! Finally, I will attach the modified plugin package, hope everyone can use it! Translated to American English: Tutorial is very simple, although this browsing value is just self-deception, but it may also be an initial operating method! Hope it can help all the little friends! Finally, I will attach the modified plugin package, hope everyone can use it!
WP-Postviews plugin modified version download address
[infobox title="Code:"]zdjr [/infobox]
[bdbtn]https://pan.baidu.com/s/1ZffsY5CV2Fby4-jXySIwcg[/bdbtn]