A-A+
去掉 wordpress 首页评论区用户链接
![Shrimp-虾米-原创文章](/wp-content/themes/Ality/img/007.gif)
【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】
打开对应文件,路径为:\wp-includes\comment-template.php
查找function get_comment_author_link 代码约再第219行,把此函数修改为如下:
function get_comment_author_link( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
$url = get_comment_author_url( $comment );
$author = get_comment_author( $comment );
$return = "[".$author."]";
/**
* Filters the comment author's link for display.
*
* @since 1.5.0
* @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
*
* @param string $return The HTML-formatted comment author link.
* Empty for an invalid URL.
* @param string $author The comment author's username.
* @param int $comment_ID The comment ID.
*/
return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
}
保存即可。
那为什么是修改此函数呢? 如下查找方法,
你的每个评论都会有个class样式,名字是:comment-author-link
通过全局搜索php发现,这个样式在 \wp-includes\widgets\class-wp-widget-recent-comments.php 这个文件中。
具体是在public function widget 这个公共函数里面。 仔细分析发现,这个样式里面调用了 get_comment_author_link 这个函数。
这个函数就在上面的文件中,那修改上面的文件就OK了。
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏