Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Disable Auto Linking of URLs in WordPress Comments

One of our readers recently asked if there’s a way to disable auto-linking of URLs in the WordPress comments.

Luckily, there is!

By default, WordPress automatically turns plain text URLs into clickable links in the comments section. This can be useful, but those links can make your comments look messy. Even worse, spammers might exploit this auto-linking feature to trick people into clicking on their harmful links.

At WPBeginner, we usually mark these comments as spam, but we know that’s not the best solution for everyone, especially if you’re running a new blog. Having a lively comment section is a great way to spark conversations and engage with your audience.

After trying out different methods – both manual and plugin options – we found that the easiest way to disable URL auto-linking is to use WPCode.

In this article, we’ll show you step-by-step instructions on how to disable auto-linking of URLs in WordPress comments.

Disabling auto-linking of URLs

Why Does WordPress Autolink Text URLs in Comments?

WordPress automatically converts text URLs into links, making 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 the screen in the admin area and in the comments section below your articles.

Text URLs auto-linked in WordPress

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

With that in mind, we will show you how to disable auto-links of URLs in WordPress comments. Here are the steps you’ll need to take:

Easy, right? Let’s jump right in!

Before we start, do note that many WordPress experts will tell you to add a custom line of code to your theme’s functions.php file or in a site-specific plugin.

However, we don’t recommend this method as it’s not really beginner-friendly. One tiny mistake, and your site might stop working.

To do this easily and safely, you can use WPCode, which is the best code-snippet plugin on the market. With WPCode, you can add custom code snippets, including CSS, PHP, HTML, and more, to WordPress without putting your site at risk.

The best news is that WPCode comes with a library of 100+ ready-made snippets that you can easily add to your site. This includes a code snippet for disabling comment URL linking.

Since it’s a premium feature, you’ll need to create a WPCode account. On the WPCode website, go ahead and click the ‘Get WPCode Now’ button.

Then, you can just simply choose a plan and complete the sign-up process.

WPCode's homepage

Once done, let’s install and activate the WPCode plugin on your WordPress site. If you need help, then you can refer to our guide on how to install a WordPress plugin.

Upon activation, you’ll need to activate your license key. To do this, you’ll navigate to Code Snippets » Settings.

Next, under the ‘General Settings’ tab, simply enter your license key and click ‘Verify Key.’ You can find this key in the email you receive after registration or in your WPCode account.

Activating WPCode license key

The next step is to go to Code Snippets » + Add Snippets from your WordPress admin area.

From here, you’ll want to use the ‘Comments’ filter to easily find the ‘Disable Comment URL Linking’ snippet. Then, you can hover over the snippet and click on the ‘Connect to library to unlock (Free)’ button.

Connecting the WPCode plugin to WPCode Library

On the popup that appears, go ahead and click ‘Connect to WordPress.’

Once connected, you should then be ready to use the ‘Disable Comment URL Linking’ snippet. So, let’s hover over it again and click ‘Use snippet’ when it appears.

Use Disable Comment URL Linking snippet

This will redirect you to the WPCode code editor.

Since the code snippet is ready to use, you just need to switch the toggle from ‘Inactive’ to ‘Active’ and click the ‘Save Snippet’ button.

Activate and save the Disable Comment URL Linking snippet

Important: Please note that this code only works on plain text URLs. If a user decides to create a link by adding the proper HTML tag, then those links will appear as they should. If you want to completely turn off any HTML in comments, then you can take a look at our tutorial on how to disable HTML in WordPress comments.

And that’s it!

Your WordPress site will now stop auto-linking URLs in comments. Here’s what it looks like on our demo site:

Auto linking of URLs in comments disabled

Explaining the Code Snippet to Disable Auto-Linking in Comments

If you’re curious, here’s the code snippet we used for disabling auto-links of URLs in WordPress comments:

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

This snippet works because WordPress doesn’t store URLs as clickable links in its database.

Instead, it converts plain text URLs into clickable links on the fly when displaying comments. By disabling the filter responsible for this, you stop URLs from automatically becoming clickable. This change will affect both the admin area and the comments section below your posts.

If you remove the snippet later, WordPress will start auto-linking URLs again.

For example, if you add this code to your theme’s functions.php file, updating your theme to the latest version will overwrite the file. To prevent this, you can consider using a child theme or a site-specific plugin.

We hope this article helped you disable the auto-linking of URLs in WordPress comments. Next up, you may also want to see our expert picks of the best plugins to improve WordPress comments and our guide on how to allow users to edit their 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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

23 CommentsLeave a Reply

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Deniz

    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

      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

  3. Febri Tri Harmoko

    How to make except like our domain?

    So, only link from our website can add.

    • WPBeginner Support

      At the moment we do not have a method to limit by domain.

      Admin

  4. Pasquale

    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

      Glad our guide was helpful :)

      Admin

  5. Geospatial &Space Technology

    Thank you for this

    • WPBeginner Support

      You’re welcome :)

      Admin

  6. Abdulrahim safi

    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

  7. Liz

    Do you guys have a similar solution for posts? Especially in code and pre blocks?

  8. Sunny

    Is there a plugin to un-link some certain external text link on WordPress site? Thanks

  9. Sebastien

    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

      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

  10. StageCoachDriver

    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?

  11. Angel

    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

      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

        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

      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.

  12. Iswandi

    It works after I remove the quotation marks at the ‘make_clickable’

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.