花静静的绽放 發表於 2023-8-30 00:00:00

去除wordpress中评论中的nofollow的方法

<p>
<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>我们先来看一下什么是nofollow。NoFollow是Google几年前提出的一个新标签,目的是减少垃圾留言。此标签表明链接与网站作者无关,也就是说搜索引擎不会用这个链接计算网站的 PR值。很多博客程序都会自动在评论链接中加上nofollow标签。现在主流的Blog程序,如WordPress和MovableType、z-blog等等,均默在其留言的链接中自动添加nofollow属性。在wordpress中加的是rel=” external nofollow”.例:Mitzie Farrer这段代码是沉缘seo在自己的小站源代码中找到的external nofollow 属性。</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>  那么nofollow与external nofollow有区别吗?在没明白二者的区别前我们先来了解一下二者的意思,rel=’external nofollow’与rel=’nofollow’其功能就中文译文”不要读取” 及”外部链接不要读取”的意思!由此可见二者的作用是相同的,只不过external nofollow是比nofollow更专业的写法,即明确指出链接为外部链接,蜘蛛可以略过。</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>  当我们不想让评论中的链接带有nofollow或者external nofollow属性时,该怎么去掉呢?</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>  那么请打开我们的wordpress,然后找到wp-include文件夹,打开comment-template.php页面,找到如下代码:</span></p>
<div style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p style="margin: 0px; padding: 0px; outline: none; float: right; line-height: 25.2px; font-size: 14px;">
<span style="line-height: 25.2px; cursor: pointer;"><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
  <br>
function get_comment_author_link( $comment_ID = 0 ) {<br>
  /** @todo Only call these functions when they are needed. Include in if... else blocks */<br>
  $url = get_comment_author_url( $comment_ID );<br>
  $author = get_comment_author( $comment_ID );<br>
  if ( empty( $url ) || 'http://' == $url )<br>
  $return = $author;<br>
  else<br>
  $return = "$author";<br>
  return apply_filters('get_comment_author_link', $return);<br>
  }</p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>  在这些代码,去掉rel='external nofollow'或者把这行代码换做target=’_blank’。这样我们的评论中就不会再出现external follow了。</span></p>
頁: [1]
查看完整版本: 去除wordpress中评论中的nofollow的方法