流量小,请求互加[友情]链接也会比较少.网站访问人多了, 自然请求就会越来越多.我在 这篇文章里 表达了暂时不想加入这么一个页面的意思.因为三天两头要添加,很乱,很麻烦.
网站越来越多留言,但是留言在页面的链接是被自动加入 [rel = external no follow] 的 HTML 标记,也就是说不会对搜索引擎SEO产生任何影响.但是我又想鼓励大家勇跃参于讨论,于是我想了一个方法.也就是创建这么一个页面 用于统计留言次数最多的前十名评论者.暂时十名, 以后根据留言数目,等流量上去了再扩大也不迟.
这个页面的好处是,可以查看哪个博主的[友情]最深,并且可以根据这个自动加入友情链接.
如何做的?
技术部分,很简单,只需要先下载一个插件 (Simple Include PHP and HTML) 然后创建一个页面, 代码如下:
然后到主题的目录下,添加这个 cmt.php 代码如下 (PHP+MySQL 就是强大啊) [同步到英文博客]
<?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."";
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 的.这个页面能保证排名榜上的链接都是真正意义上的 [友情] 链接.
本文一共 419 个汉字, 你数一下对不对.上一篇: 在英国出生的孩子的签证
下一篇: 孩子教育的两则小故事
扫描二维码,分享本文到微信朋友圈
![php-plugin-comment 再说友情链接 [评论统计页面] 互联网 技术 折腾 程序员 网站信息与统计 php-plugin-comment 再说友情链接 [评论统计页面] 互联网 技术 折腾 程序员 网站信息与统计](https://justyy.com/wp-content/uploads/2014/10/php-plugin-comment.jpg)
我以前见过有些朋友有读者墙页面,放在内页或者侧边,按评论数排的.
嗯嗯, 这也是一种方法.
你越来越会考虑用户友好~提高粘度的事情了啊.
你的好多功能都是要通过Simple Include PHP and HTML这个插件实现哈.
是啊, 这个插件挺好的, 然后就可以在页面里写PHP了,一个插件省去N个插件还是值的.
读者墙当然也是可以通过代码实现的,不过你直接把这个当做友情链接想法还是不错的.
这确实是一个好方法!一劳永逸啊!