移除 WordPress 评论的网址URL表单及评论人链接

一般我们使用的WordPress主题的评论提交中,都包含了“网址”这个表单,有些博主不希望别人提交网址,其实你可以很方便地移除网址表单;如果之前已经有一些评论包含了评论人网址,你还可以直接移除。在主题的 functions.php 添加下面的代码即可:

/**
 * 移除 WordPress 评论的网址URL表单及评论人链接
 * https://www.wpdaxue.com/remove-wordpress-comments-url.html
 */
//移除网址表单
function url_filtered($fields)
{
if(isset($fields['url']))
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'url_filtered');
 
//移除评论人名字的链接
function disable_comment_author_links( $author_link ){
	return strip_tags( $author_link );
}
add_filter( 'get_comment_author_link', 'disable_comment_author_links' );

 

最终效果如下:

wpdaxue.com-201303499

注:此方法只对使用 WordPress 默认评论表单的主题才有效,如果主题自定义过评论功能,是没办法生效的,只能靠自己修改主题的自定义评论文件。比如打开主题的 comments.php 文件,搜索 $comment_author_url 一般就可以定位到网址表单的代码。

disable_comment_author_links-wpdaxue_com

来源:

https://www.wpdaxue.com/remove-wordpress-comments-url.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33158.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?