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

WordPressのコメントでURLの自動リンクを無効化する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

ユーザーがコメントにプレーンテキストのURLを追加すると、WordPressは自動的にそれをクリック可能にすることをご存知ですか?最近、ある読者からWordPressのコメントでテキストURLの自動リンクを無効化できないかという質問を受けました。という質問がありました。この投稿では、WordPressのコメントでURLの自動リンクを無効化する方法をご紹介します。

なぜWordPressはコメントするテキストURLを自動リンクするのか?

WordPressは自動的にテキストURLをリンクに変換し、コメントする際のモデレーションを容易にします。

この自動リンクはデータベースには保存されません。WordPressは、投稿の下にあるコメント欄だけでなく、管理エリアでもURLを画面に表示する際にクリックできるようにします。

Auto-linked clickable text URL in WordPress comments

このようなコメントの中には、コメントする人がリンクの貼り方を知らなかった本物のコメントもあります。しかし、多くのスパムコメントには、コメント文に直接貼り付けられたプレーンなURLも含まれている。

WordPressのコメントで自動リンクを無効化する

テーマのfunctions.phpファイルまたはサイト固有のプラグインに、この個別コードを1行追加するだけです。

[cbk1]

WordPressは、プレーンテキストのURLをリンクとしてデータベースに保存しません。その代わりに、その場でクリック可能なリンクに変更します。このコードはURLをクリック可能にするフィルターを無効化するだけです。

これにより、プレーンテキストのURLは管理エリアや投稿下のコメント欄でクリックできなくなります。このコードを削除すると、自動リンクが再び有効化されます。

このコードをテーマのfunctions.phpファイルに追加している場合、テーマを更新するとfunctionsファイルが上書きされます。

また、このコードはプレーンテキストのURLに対してのみ機能することを覚えておいてください。ユーザーが適切なHTMLタグを追加してリンクを作成した場合は、リンクはそのまま表示されます。

コメントのHTMLを完全に無効にしたい場合は、WordPressコメントのHTMLを無効化する方法のチュートリアルをご覧ください。

この投稿がWordPressコメントでURLの自動リンクを無効化するのにお役に立てば幸いです。WordPressのコメントを改善する16のベストプラグインのリストもご覧ください。

この投稿が気に入った場合は、WordPressの動画チュートリアルをYouTubeチャンネルに登録してください。Twitterや Facebookでもご覧いただけます。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

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.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

23件のコメント返信を残す

  1. Syed Balkhi says

    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 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!

      管理者

  3. 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

  4. 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

  5. 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

  6. 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?

  7. 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.

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。