再说友情链接 [评论统计页面]


流量小,请求互加[友情]链接也会比较少.网站访问人多了, 自然请求就会越来越多.我在 这篇文章里 表达了暂时不想加入这么一个页面的意思.因为三天两头要添加,很乱,很麻烦.

网站越来越多留言,但是留言在页面的链接是被自动加入 [rel = external no follow] 的 HTML 标记,也就是说不会对搜索引擎SEO产生任何影响.但是我又想鼓励大家勇跃参于讨论,于是我想了一个方法.也就是创建这么一个页面 用于统计留言次数最多的前十名评论者.暂时十名, 以后根据留言数目,等流量上去了再扩大也不迟.

这个页面的好处是,可以查看哪个博主的[友情]最深,并且可以根据这个自动加入友情链接.

如何做的?

技术部分,很简单,只需要先下载一个插件 (Simple Include PHP and HTML) 然后创建一个页面, 代码如下:

php-plugin-comment 再说友情链接 [评论统计页面] 互联网 技术 折腾 程序员 网站信息与统计

评论统计页面

然后到主题的目录下,添加这个 cmt.php 代码如下 (PHP+MySQL 就是强大啊) [同步到英文博客]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// https://codingforspeed.com
  global $wpdb;
  $query = "
    select 
      `comment_author`, 
      `comment_author_url`,
      count(1) as `cnt` 
    from
      `wp_comments`
    where
      `comment_approved` = 1      
    group by 
      `comment_author`
    order by
      `cnt` desc
    limit 10 
  ";
  
  $result = $wpdb->get_results($query);
  if ($result) {
    echo "<table width='100%' style='border:0'>";
    echo "<tr><b><td>作者</td><td>评论数目</td></b></tr>";
    foreach ($result as $author) {
      echo "<tr>";
      $a = esc_sql($author->comment_author);
      $query = "
        select 
          `comment_post_id`,
          `comment_id`
        from
          `wp_comments`
        where
          `comment_approved` = 1 and
          `comment_author` = '$a'
        order by
          `comment_date` desc
        limit 1      
      ";
      $latest = $wpdb->get_row($query);
      echo "<td><a href='$author->comment_author_url' target='_blank' title='$author->comment_author'>".$author->comment_author."</a></td>";
      echo "<td><a title='$author->comment_author' href='/archives/$latest->comment_post_id/#comment-$latest->comment_id'>".$author->cnt."</a></td>";      
      echo "</tr>";
    }
    echo "</table>";
  } 
?>
<?php
// https://codingforspeed.com
  global $wpdb;
  $query = "
    select 
      `comment_author`, 
      `comment_author_url`,
      count(1) as `cnt` 
    from
      `wp_comments`
    where
      `comment_approved` = 1      
    group by 
      `comment_author`
    order by
      `cnt` desc
    limit 10 
  ";
  
  $result = $wpdb->get_results($query);
  if ($result) {
    echo "<table width='100%' style='border:0'>";
    echo "<tr><b><td>作者</td><td>评论数目</td></b></tr>";
    foreach ($result as $author) {
      echo "<tr>";
      $a = esc_sql($author->comment_author);
      $query = "
        select 
          `comment_post_id`,
          `comment_id`
        from
          `wp_comments`
        where
          `comment_approved` = 1 and
          `comment_author` = '$a'
        order by
          `comment_date` desc
        limit 1      
      ";
      $latest = $wpdb->get_row($query);
      echo "<td><a href='$author->comment_author_url' target='_blank' title='$author->comment_author'>".$author->comment_author."</a></td>";
      echo "<td><a title='$author->comment_author' href='/archives/$latest->comment_post_id/#comment-$latest->comment_id'>".$author->cnt."</a></td>";      
      echo "</tr>";
    }
    echo "</table>";
  } 
?>

你们觉得这样的功能是不是好些呢?

后注:坛子说, 这个其实就是读者墙的功能,但是那个是插件实现的,略为有点复杂.而且说不定读者墙的链接也是 nofollow 的.这个页面能保证排名榜上的链接都是真正意义上的 [友情] 链接.

GD Star Rating
loading...
本文一共 419 个汉字, 你数一下对不对.
再说友情链接 [评论统计页面]. (AMP 移动加速版本)
上一篇: 在英国出生的孩子的签证
下一篇: 孩子教育的两则小故事

扫描二维码,分享本文到微信朋友圈
7dfc08b0de4e49a990c80dd448edd8d9 再说友情链接 [评论统计页面] 互联网 技术 折腾 程序员 网站信息与统计

10 条评论

  1. 锦程

评论