How to Disable Auto Linking of URLs in WordPress Comments
Did you know that when a user adds a regular text URL in his comments, WordPress makes it automatically clickable? Recently one of our readers asked us if it was possible to disable the automatic linking of text URLs in WordPress responses. The answer is yes. In this article, we’ll show you how to disable the automatic linking of URLs in WordPress comments.
WordPress automatically converts text URLs into links, making it easier to visit the link while moderating comments.
Some of these comments are genuine if commentators did not know how to add a link in comments. But many spam comments also contain regular URLs that are pasted directly into the response text.
Simply add this line code to the function.php file of your theme or in a site-specific plug-in.
remove_filter( 'comment_text', 'make_clickable', 9 );
WordPress does not store plain text URLs as links in the database. Instead, it immediately changes into clickable links. With this code, the filter that clicks on URLs is simply disabled.
This makes plain text URLs non-clickable in the administrative areas and responses section of your messages. If you delete this code, automatic pairing will be re-enabled.
If you add it to the function.php file of your theme, updating your theme will overwrite your function file.
Also, keep in mind that this code only works for URLs with plain text. If a user has decided to create a link by adding the correct HTML tag, those links will be displayed as they should.
We hope this article helped you disable automatic linking of URLs in WordPress comments.