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

Så här inaktiverar du automatisk linkning av URL:er i WordPress Comments

Visste du att när en användare addar en plain text URL i sina comments, WordPress gör den automatiskt klickbar. Nyligen frågade en av våra läsare oss om det var möjligt att inaktivera automatisk länkning av text URL i WordPress kommentarer? Svaret på frågan är JA. I den här artikeln visar vi dig hur du inaktiverar automatisk länkning av URL:er i WordPress comments.

Varför autolänkar WordPress text-URL:er i kommentarer?

WordPress konverterar automatiskt text-URL:er till links vilket gör det lättare att besöka länken när du granskar kommentarer.

Denna auto-linking lagras ej i din database. WordPress gör URL:er klickbara när de visas på vy i admin area samt i comments section under your articles.

Auto-linked clickable text URL in WordPress comments

Vissa av dessa kommentarer är äkta där kommentatorer inte visste hur man addar en link i kommentarer. Men många skräppostkommentarer innehåller också vanliga URL:er som klistras in direkt i kommentartexten.

Inaktivera Auto-Link i WordPress Comments

Lägg bara till denna enda kodrad i ditt temas functions.php-fil eller i ett site-specifikt plugin.

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

WordPress lagrar inte URL:er i plain text som links i databasen. Istället ändrar den dem till klickbara links i farten. Den här koden inaktiverar helt enkelt filtret som gör URL:er klickbara.

Detta gör URL:er i plain text icke-klickbara i admin area och i comments section under your posts. Om du tar bort den här koden aktiveras den automatiska linkningen igen.

Om du lägger till den i ditt temas functions.php-fil, kommer updating av ditt theme att skriva över din functions-fil.

Tänk också på att den här koden bara fungerar på URL:er med plain text. Om en användare bestämde sig för att skapa en länk genom att lägga till rätt HTML-tagg, kommer dessa links att visas som de ska.

Om du vill inaktivera all HTML i kommentarer helt och hållet, ta en titt på vår tutorial om hur du inaktiverar HTML i WordPress-kommentarer.

Vi hoppas att den här artikeln hjälpte dig att inaktivera automatisk linkning av URL:er i WordPress comments. Du kanske också vill se vår lista över de 16 bästa tilläggen för att förbättra WordPress comments.

Om du gillade den här artikeln, vänligen prenumerera på vår YouTube-kanal för WordPress video tutorials. Du kan också hitta oss på Twitter och Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

23 kommentarerLämna ett svar

  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!

      Administratör

  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.

      Administratör

  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 :)

      Administratör

  5. Geospatial &Space Technology

    Thank you for this

    • WPBeginner Support

      You’re welcome :)

      Administratör

  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’

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.