url wordpress_如何在WordPress注释中禁用URL的自动链接

url wordpress

Did you know that when a user adds a plain text URL in their comments, WordPress automatically makes it clickable. Recently, one of our readers asked us if it was possible to disable auto-linking of text urls in WordPress comments? The answer is YES. In this article, we will show you how to disable auto-linking of URLs in WordPress comments.

您是否知道,当用户在其注释中添加纯文本URL时,WordPress会自动使其可单击。 最近,一位读者问我们是否可以禁用WordPress注释中文本网址的自动链接? 答案是肯定的。 在本文中,我们将向您展示如何禁用WordPress注释中的URL自动链接。

为什么WordPress自动链接评论中的文本URL? (Why WordPress Autolinks Text URLs in Comments?)

WordPress automatically converts text URLs into links which makes it easier to visit the link while moderating comments.

WordPress自动将文本URL转换为链接,这使得在审核评论时更容易访问该链接。

This auto-linking is not stored in your database. WordPress makes URLs clickable when displaying them on screen in admin area as well as comments section below your articles.

此自动链接未存储在数据库中。 当在管理区域以及文章下方的评论部分中显示它们时,WordPress使URL可单击。

Auto-linked clickable text URL in WordPress comments

Some of these comments are genuine where commenters didn’t know how to add a link in comments. But many spam comments also contain plain URLs pasted directly in the comment text.

其中一些评论是真实的,其中评论者不知道如何在评论中添加链接。 但是,许多垃圾评论也包含直接粘贴在评论文本中的纯URL。

在WordPress注释中禁用自动链接 (Disabling Auto-Link in WordPress Comments)

Simply add this single line of code in your theme’s functions.php file or in a site-specific plugin.

只需将这一行代码添加到主题的functions.php文件或特定站点的插件中


remove_filter( 'comment_text', 'make_clickable', 9 );

WordPress does not store plain text URLs as links in the database. Instead it changes them into clickable links on the fly. This code simply disables the filter that makes URLs clickable.

WordPress不会将纯文本URL作为链接存储在数据库中 。 而是将它们动态更改为可点击的链接。 此代码仅禁用使URL可单击的过滤器。

This makes plain text URLs non-clickable in admin area and comments section below your posts. Removing this code will re-enable the auto linking.

这将使纯文本URL在帖子下方的管理区域和评论部分中不可单击。 删除此代码将重新启用自动链接。

If you are adding it to your theme’s functions.php file, then updating your theme will overwrite your functions file.

如果将其添加到主题的functions.php文件中,则更新主题将覆盖函数文件。

Also keep in mind that this code only works on plain text URLs. If a user decided to create a link by adding the proper HTML tag, then those links will appear as they should.

另外请记住,此代码仅适用于纯文本URL。 如果用户决定通过添加适当HTML标签来创建链接,则这些链接将按原样显示。

If you want to complete turn off any HTML in comments, then take a look at our tutorial on how to disable HTML in WordPress comments.

如果要完成关闭注释中的所有HTML,请查看我们的有关如何在WordPress注释中禁用HTML的教程。

We hope this article helped you disable auto linking of URLs in WordPress comments. You may also want to see our list of 16 best plugins to improve WordPress comments.

我们希望本文能帮助您禁用WordPress注释中URL的自动链接。 您可能还希望查看我们的16个最佳插件列表, 以改善WordPress评论

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-disable-auto-linking-of-urls-in-wordpress-comments/

url wordpress

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值