wordpress除去评论者和评论内容链接 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

  Spam泛滥的时代如何控制好WordPress不被这些评论内容链接链接导致网站被K,影响到整站的SEO,这是很重要的,

wordpress除去评论者和评论内容链接

WordPress除去评论者和评论内容链接

  把如下代码加入主题模板函数functions.php文件中,修改前记得先备份functions.php文件,加在中间即可。

<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">function</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">remove_comment_links</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span>
global $comment<span class="sh_symbol">;</span>
$url <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_comment_author_url</span><span class="sh_symbol">();</span>
$author <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_comment_author</span><span class="sh_symbol">();</span>
<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span> <span class="sh_symbol">(</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">empty</span><span class="sh_symbol">(</span> $url <span class="sh_symbol">)</span> <span class="sh_symbol">||</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'http://'</span> <span class="sh_symbol">==</span> $url <span class="sh_symbol">)</span>
$<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> <span class="sh_symbol">=</span> $author<span class="sh_symbol">;</span>
<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">else</span>
$<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> <span class="sh_symbol">=</span> $author<span class="sh_symbol">;</span>
<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> $<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span><span class="sh_symbol">;</span>
<span class="sh_cbracket">}</span>
<span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">add_filter</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'get_comment_author_link'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'remove_comment_links'</span><span class="sh_symbol">);</span>
<span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">remove_filter</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'comment_text'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'make_clickable'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">9</span><span class="sh_symbol">);</span>

  这样设置以就可以除去WordPress评论者和评论内容链接,

电脑资料

wordpress除去评论者和评论内容链接》(https://www.unjs.com)。

最新文章