小胡经过长时间的研究,终于在萧涵V3.0版本的主题中添加上了评论链接跳转,和别人的修改方法稍微有点不一样的!
第一步,建立URL跳转的PHP文件
1.在博客根目录下新建r.php,放入以下代码
<?php
$url = $_GET['url'];
Header("Location:$url");
?>
2.在网站robots.txt文件中放入以下代码
Disallow: /r.php?url=*
第二步,修改WordPress文件
打开主题文件中的functions.php
找到:
<a id="commentauthor-<?php comment_ID() ?>" href="<?php comment_author_url() ?>" rel="external nofollow" title="<?php comment_author(); ?>" target="_blank">
改为:
<a id="commentauthor-<?php comment_ID() ?>" href="/r.php?url=<?php comment_author_url() ?>" rel="external nofollow" title="<?php comment_author(); ?>" target="_blank">
这样就OK啦!