Chinaunix首页 | 论坛 | 博客
  • 博客访问: 716866
  • 博文数量: 235
  • 博客积分: 4309
  • 博客等级: 中校
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 11:25
个人简介

If you don\\\\\\\\\\\\\\\'t wanna do it, you find an EXCUSE; if you do, you\\\\\\\\\\\\\\\'ll find a WAY :-)

文章分类

全部博文(235)

文章存档

2014年(3)

2013年(2)

2012年(31)

2011年(199)

分类: LINUX

2011-10-30 22:29:26

  1. WordPress 统计文章浏览数代码
  2. # vim functions.php ( SHIFT -g 在最后加入)
  3. /* added by ko */
  4. function getPostViews($postID){
  5. $count_key = ‘post_views_count’;
  6. $count = get_post_meta($postID, $count_key, true);
  7. if($count==”){
  8. delete_post_meta($postID, $count_key);
  9. add_post_meta($postID, $count_key, ’0′);
  10. return “0 View”;
  11. }
  12. return ‘浏览:’.$count;
  13. }
  14. function setPostViews($postID) {
  15. $count_key = ‘post_views_count’;
  16. $count = get_post_meta($postID, $count_key, true);
  17. if($count==”){
  18. $count = 0;
  19. delete_post_meta($postID, $count_key);
  20. add_post_meta($postID, $count_key, ’0′);
  21. }else{
  22. $count++;
  23. update_post_meta($postID, $count_key, $count);
  24. }
  25. } ?>
  26. 提示:为了方便可以将代码直接复制到编辑器如 mousepad 保存到文件 article-stat.php,接着:
  27. # cat article-stat.php >> function.php
  28. # vim single.php (在 the_content 上方加入代码:)
  29. 欢迎转载,请保留本文链接:” title=””>

  30.   

  31. :wq
阅读(730) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~