|
|
搜索看看︰WordPress 评论外链跳转
WordPress的评论经常会出现垃圾评论,外链一大堆,开启手工审核吧一个一个看也麻烦。前段时间从网上看到一个方法还不错,可以将评论处的外链前面加上自己网站的地址例如:http://域名/plus/links.php?url=http://abc.com 这种格式,这样是为了站点的SEO能够对各种搜索引擎更友好,更重要的是起到了保护自己域名权重的目的。
中间的过渡,很好地避免了外链的导出,又很好的到达了目标网站,是一个两全齐美的好东东。
下面我跟大家分享一下这个方法:
首先下载:在WordPress根目录创建plus文件夹,将下面的代码存为links.php,上传至plus目录:- <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title><?php echo '页面跳转 | 爱斯诺 | isnowe.com'; ?></title><head><style type="text/css">body{background:#eaeaea;} #box{border:1px solid #bbb;padding:20px;width:600px;height:80px;margin:10% auto 0 auto;box-shadow:2px 2px 2px #ddd;background:#fafafa; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; /*IE8*/filter:alpha(opacity=70); /*IE5、IE5.5、IE6、IE7*/opacity: .7; /*Opera9.0+、Firefox1.5+、Safari、Chrome*/} #box h1{color:#B1234A;font-size:26px;text-align:center;font-family:"微软雅黑"}</style></head><body><div id="box"><h1><a href="http://isnowe.com">爱斯诺</a>正在为您跳转中... 请稍等...</h1></div><?php $url=$_GET["url"]; echo "<script language='Javascript'>"; echo "location='$url';"; echo "</script>"; ?></body></html>
複製代碼 然后在你主题目录内找到functions.php文件用DW或者NOTPAD++打开在最上面开始第一个<?php 标签下面加上下面这段:- //评论链接url跳转 add_filter('get_comment_author_link', 'add_redirect_comment_link', 5);add_filter('comment_text', 'add_redirect_comment_link', 99);function add_redirect_comment_link($text = ''){$text=str_replace('href="', 'target="_blank" href="'.get_option('home').'/plus/links.php?url=', $text );$text=str_replace("href='", "target='_blank'href='".get_option('home')."/plus/links.php?url=", $text );return $text;}add_action('init', 'redirect_comment_link');function redirect_comment_link(){$redirect = $_GET['r'];if($redirect){if(strpos($_SERVER['HTTP_REFERER'],get_option('home')) !== false){header("Location: $redirect");exit;}else {header("Location: http://isnowe.com/");exit;}}}
複製代碼 WordPress v3.5.2 简体中文版下载
WordPress 评论外链跳转
WordPress 评论外链跳转
界面预览
- 软件大小:6.28MB
- 软件类别:国外软件 | 博客系统
- 软件语言:简体中文
- 运行环境:PHP/Mysql
- 软件授权:免费版
- 更新时间:2013-7-24 16:05:30
- 相关链接:Home Page
|
|