我正在使用WP Post Views 显示帖子视图数的插件。为此,我使用:
<?php if(function_exists(\'the_views\')) { the_views(); } ?>
The problem is: 如果用户只是刷新帖子页面,插件会增加帖子视图的数量。如果特定用户的视图数量只增加一次,那就好了。谢谢你抽出时间。非常感谢您一如既往的帮助。
指向代码源的链接为:http://plugins.trac.wordpress.org/browser/wp-postviews/trunk/wp-postviews.php
Note:
在SE社区的帮助下,我已经使用以下黑客方法排除了帖子作者的观点:function remove_view_counter_wpse_102637() {
global $post;
$current_user = wp_get_current_user();
if (
is_single()
&& !empty($current_user)
&& $post->post_author == $current_user->ID
) {
remove_action(\'wp_head\', \'process_postviews\');
}
}
add_action(\'wp_head\', \'remove_view_counter_wpse_102637\',1);
但我无法使用相同的逻辑排除同一用户的多个计数。