时间:2021-07-01 10:21:17 帮助过:4人阅读
1.首先在主题下functions.php里增加以下代码,这段代码也是网上可以找到的
getPostViews( = 'post_views_count' = get_post_meta(, , ( == '' delete_post_meta(, add_post_meta(, , '0' "0" setPostViews( = 'post_views_count' = get_post_meta(, , ( == '' = 0 delete_post_meta(, add_post_meta(, , '0' } ++ update_post_meta(, , }
2.解决刷新统计数增加,一定要放在文章页面的最前面,貌似php设置cookie之前不能有输出,蛋疼。我的是single.php页面
= ((['views'..COOKIEHASH]) && ['views'..COOKIEHASH] == '1'
setPostViews( ('views'..COOKIEHASH,'1',() + 3600,COOKIEPATH,COOKIE_DOMAIN);
?>
http://www.bkjia.com/PHPjc/440188.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440188.htmlTechArticlewordpress本身不带文章浏览统计,可以用插件wp-postview,但是刷新还是算一个浏览次数。 1.首先在主题下functions.php里增加以下代码,这段代码...