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.
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.
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.
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.
Disabling Auto-Link in WordPress Comments
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.
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.
If you are adding it to your theme’s functions.php file, then updating your theme will overwrite your functions file.
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.
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.
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.