【发布时间】:2015-11-20 06:06:34
【问题描述】:
我在网上搜索了一种通过刷新页面来禁用帖子/页面视图“黑客”的方法,但我没有找到任何方法。
如何不通过刷新增加页面/帖子查看次数?
或不同角度的相同问题:
如何只注册唯一访问?
我目前的想法是IP 或nonce 但恐怕我需要一点帮助才能开始。
目前的代码超级简单:
/* Allow devs to override the meta key used. By default, this is 'Views'. */
$meta_key = 'estate_property_views_count';
/* Get the number of views the post currently has. */
$old_views = get_post_meta( $post_id, $meta_key, true );
/* Add +1 to the number of current views. */
$new_views = absint( $old_views ) + 1;
/* Update the view count with the new view count. */
update_post_meta( $post_id, $meta_key, $new_views, $old_views );
【问题讨论】:
标签: php