Family Encyclopedia >> Electronics

How to disable URL autolinking in WordPress comments

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

Why WordPress Autolinks Text URLs in Comments?

WordPress automatically converts text URLs to links, making it easy to visit the link and moderate comments.

This automatic link is not stored in your database. WordPress makes URLs clickable when they are displayed in the admin area as well as in the comments section below your articles.

How to disable URL autolinking in WordPress comments

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

Disabling Auto-Link in WordPress Comments

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

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

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

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

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

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

If you'd like to complete disable any HTML in comments, check out our tutorial on how to disable HTML in WordPress comments.

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

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