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
Simply add this single line of code in your theme’s functions.php file or in 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 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.
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.
Deniz says
Thanks for the guide. I added the code to function.php and it worked. So is there a way to exclude my own links from this?
WPBeginner Support says
We do not have a simple way at the moment but should we find a way we would recommend we will be sure to update the article!
Admin
Febri Tri Harmoko says
How to make except like our domain?
So, only link from our website can add.
WPBeginner Support says
At the moment we do not have a method to limit by domain.
Admin
Pasquale says
Thanks, this was helpful. I was getting a lot of comments like ‘your website is great…bla bla…check mine’ and a link. Hopefully this will fix it
WPBeginner Support says
Glad our guide was helpful
Admin
Geospatial &Space Technology says
Thank you for this
WPBeginner Support says
You’re welcome
Admin
Abdulrahim safi says
Hello How can i disable auto link in posts not comments
when i enter a link in text format ex: http://www.example.com it is automatically changed to hyperlink when i publish post how can i disable this thanks
WPBeginner Support says
Abdulrahim Saifi,
WordPress doesn’t automatically convert URLs into links. You are probably using WordPress.com. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
Admin
Liz says
Do you guys have a similar solution for posts? Especially in code and pre blocks?
Kemunto says
Yes.
Sunny says
Is there a plugin to un-link some certain external text link on WordPress site? Thanks
Sebastien says
Hello. I’m looking for a way to do just what you mentioned, but only for posts. It seems with a recent WP update, if you type a website address in a post, WP will automatically link to it. For example, if your post contains “google.com” somewhere in the post, then WP will add a link to google. Can we stop that from happening? If so, how? Thank you
Bobby says
Hey Sebastien did you find the solution for your problem as i am also having problem with this.. and i just want to get it disabled.. thanks
StageCoachDriver says
Could the functions.php in a child theme be used to add ‘remove_filter( ‘comment_text’, ‘make_clickable’, 9 );’ to the theme rather than making changes directly to the theme?
WPBeginner Support says
Yes.
Admin
Angel says
That is really good. In my case, I’ll make a conditional to make my links – as admin – clickable, since I post them on replies to comments.
Thanks
Matteo says
Hi Angel,
do you mind posting here the code you wrote? I’m interested in having my own links (as admin) cliackable
Thank you
Angel says
As I am the only person show logs in I am able to use:
if ( is_user_logged_in() ) {
remove_filter( ‘comment_text’, ‘make_clickable’, 9 );
}
Ibon Azkoitia says
Maybe I’m wrong about your situation, but you should not write in your Blog with an Admin User. The “Writer” should have a lower role (editor for example) and have another user with the Admin role for admin stuff.
Iswandi says
It works after I remove the quotation marks at the ‘make_clickable’