2016年已经过去, 通过以下 SQL 语句 能统计出今年一共发表了 292篇博文.
SELECT Count(1) FROM `wp_posts` WHERE `post_type` = "post" and `post_status` = "publish" and date_format(`post_date_gmt`, "%Y") = "2016"
SQL十大热门评论文章
SELECT `post_name`, `post_title` FROM `wp_posts` WHERE `post_type` = 'post' and `post_status` = 'publish' and date_format(`post_date_gmt`, "%Y") = '2016' ORDER BY `comment_count` DESC LIMIT 10
以下是 当时的排名, 如果想更多的博文, 可以手动改 limit 10 (显示10篇).
- 玩单反 穷三代
- 为啥我的网站这么快呢?
- 给老婆弄了辆小奔开开
- 你是不是浪费太多的时间?
- 在英国做痔疮绷带手术Banding的经历
- 请不要叫我博士!
- 申请 Paypal Credit 没有卡的信用卡
- 创建了一个微软azure服务器玩玩
- 酷我音乐捆绑安装就TM是一流氓软件
- 拿到SD卡或U盘后第一件事就是要好好检查
SQL十大评分博文
通过和 GD Star 评分系统结合, 就可以统计出十大评分的文章.
SELECT `p`.`ID`, `p`.`post_title` as `title`, `visitor_votes` + `user_votes` as `total_votes`, `visitor_votes`, `user_votes` FROM `wp_gdsr_data_article` as `da` INNER JOIN `wp_posts` as `p` ON `da`.`post_id` = `p`.`ID` WHERE `p`.`post_type` = 'post' and `p`.`post_status` = 'publish' and date_format(`p`.`post_date_gmt`, "%Y") = '2016' HAVING `total_votes` > 0 ORDER BY `total_votes` DESC LIMIT 10
得到评分前10名的文章 (静态的结果 并不会动态更新).
+------+---------------------------------------------------------+-------------+---------------+------------+ | ID | title | total_votes | visitor_votes | user_votes | +------+---------------------------------------------------------+-------------+---------------+------------+ | 3422 | 海外如何在线观看 2016 年巴西奥运会直播? | 106.0 | 96.0 | 10.0 | | 3954 | 什么是财务自由? 你离财务自由还有多远? | 40.0 | 30.0 | 10.0 | | 3491 | 给老婆弄了辆小奔开开 | 39.0 | 39.0 | 0.0 | | 3552 | Google 广告不再限制一页3个 | 29.0 | 29.0 | 0.0 | | 2785 | 开车一年的数据统计 | 28.0 | 28.0 | 0.0 | | 3916 | 2016年公司圣诞聚餐 | 26.0 | 16.0 | 10.0 | | 3761 | 如何下载保存新浪微博秒拍视频? | 21.0 | 11.0 | 10.0 | | 2763 | 想英国代购的有福了: 畅购英伦 上线了! | 20.0 | 10.0 | 10.0 | | 3022 | 为啥我的网站这么快呢? | 20.0 | 20.0 | 0.0 | | 3330 | SEO 优化简要清单 | 20.0 | 20.0 | 0.0 | +------+---------------------------------------------------------+-------------+---------------+------------+
- 海外如何在线观看 2016 年巴西奥运会直播?
- 什么是财务自由? 你离财务自由还有多远?
- 给老婆弄了辆小奔开开
- Google 广告不再限制一页3个
- 开车一年的数据统计
- 2016年公司圣诞聚餐
- 如何下载保存新浪微博秒拍视频?
- 想英国代购的有福了: 畅购英伦 上线了!
- 为啥我的网站这么快呢?
- SEO 优化简要清单
以上两个SQL语句都可以 稍加 group by 月份 修改 就可以按每月分组 得到每个月份中 评价或者得分最高的博文, 这里就不多重复了.
1 | group by date_format(`p`.post_date_gmt, "%M") |
group by date_format(`p`.post_date_gmt, "%M")
Wordpress博文统计
- 为博客Wordpress添加两个显示十大文章的短指令 shortcode
- 如何通过SQL语句找出得分最多的文章? (2016 年博文统计)
- 通过SQL查询2015年最受欢迎的博文
- 2020年最受欢迎的博文统计
- 2019年最受欢迎的博文统计
- 2017 年, 我的热门帖子 My Top Posts in 2017!
- 按评论排名前20的文章
- 按评分排名前20的文章
GD Star Rating
loading...
本文一共 730 个汉字, 你数一下对不对.loading...
上一篇: 入 GoPro Hero+ 运动摄像机 (简要测评)
下一篇: NPower 电力公司退了我100英镑
扫描二维码,分享本文到微信朋友圈
有时间得好好看看SQL了
SQL就如英语一样, 不用特意花时间看