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でコメントを完全に無効化する方法(究極ガイド)

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

WordPressのコメントを完全に、または部分的にオフにする方法をお探しですか?

コメントはサイト訪問者を惹きつける素晴らしい方法ですが、様々な理由からコメントを許可したくない場合もあるでしょう。特定の投稿日、ページ、カスタム投稿タイプのみから、サイト全体からコメントを完全に削除する方法まで、コメントを無効化する方法はたくさんあります。

この投稿では、WordPressでコメントを無効化する方法をステップ・バイ・ステップで紹介します。

How to Completely Disable Comments in WordPress

なぜWordPressでコメントを無効化するのか?

特定の投稿日やページへのコメントを無効にしたり、サイト全体のコメントを無効化したい理由はたくさんあります。

例えば、ブロガーはコメントを許可したくないお知らせのような特定の投稿を公開することがあります。このような場合、特定の投稿日やページへのコメントを簡単に無効化することができます。

中小企業の経営者の多くは、WordPressを使ってサイトを作成しています。このようなビジネスサイトにはブログセクションがないことが多く、サービス、会社概要、お問い合わせなどの静的なページがほとんどです。このような場合、コメントを許可することはすべて意味がありません。

また、よくあるシナリオとして、スパムを防ぐためにコメントを完全に無効化するビジネスブログもあります。スパム防止テクニック(この投稿の後半で紹介します)はいつでも使えますが、コメント欄を無効化すれば問題は確実に解決します。

コメントはエンゲージメントを高め、読者からのフィードバックを得るための素晴らしい方法ですが、その管理には時間がかかります。スパムや否定的なコメントが多い場合は特にそうです。

どのような理由であれ、コメントを無効化し、WordPressサイトからコメント欄を完全に削除することは可能です。

この投稿で学ぶことの概要を簡単に説明しよう:

最初のいくつかの方法では、プラグインを使わずにページ、投稿日、またはメディアのコメントを無効化する方法を説明する。後ほど、プラグインを使ってWordPressブログからコメント欄を削除する方法を説明する。

ということで、WordPressでコメントを無効化する様々な方法を見ていきましょう。

動画チュートリアル

Subscribe to WPBeginner

動画が気に入らなかったり、もっと説明が必要な場合は、このまま読み進めてください。

コメントを完全に無効化する

コメントを完全に無効化し、管理画面やサイトのフロントエンドからコメント関連の機能をすべて削除することは非常に簡単です。

無料のWPCodeプラグインには、あらかじめ設定されたコードスニペットのライブラリが付属しており、「Completely Disable Comments」スニペットを使用することで、サイトからコメントの痕跡をすべて取り除くことができます。

WPCodeをインストールして有効化し、WordPress管理画面のCode Snippets “ Libraryに移動します。ここで、’completely disable comments’を検索し、同じ名前の結果にマウスオーバーすることができます。

そして『スニペットを使う』をクリックすればいい。

Use new snippet in wpcode

WPCodeは、プラグインがすでにあなたのためにすべてを設定している「Edit Snippet」ページに移動します。

必要なのは、スイッチを「有効化」に切り替え、「更新」をクリックするだけだ。

The edit snippet page for WPCode

これで、WPCodeはあなたのサイトからコメント関連の機能をすべて無効化します。

サイトからすべて手動でコメントを削除したい場合は、テーマのfunctions.phpファイルに以下のコードを貼り付けてください。

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    
    if ($pagenow === 'edit-comments.php') {
        wp_safe_redirect(admin_url());
        exit;
    }

    // Remove comments metabox from dashboard
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

    // Disable support for comments and trackbacks in post types
    foreach (get_post_types() as $post_type) {
        if (post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
});

// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// Remove comments page in menu
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// Remove comments links from admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});

注:テーマファイルに直接コードスニペットを貼り付けることは、WordPressのコアファイルを編集することで簡単にサイトが壊れてしまう可能性があるため、上級ユーザーのみが行ってください。

今後の投稿日: コメントすることを無効化する。

WordPressサイトを立ち上げたばかりであれば、今後の投稿にコメントするのを簡単に止めることができます。

これを行うには、WordPress管理画面の左サイドバーから設定ディスカッションに移動します。

このページでは、”Allow people to post comments on new articles “というオプションのチェックを外し、”Save Changes“ボタンをクリックして設定を保存します。

Disable comments on future posts

これにより、今後投稿するすべての投稿でコメントすることが無効化されます。ただし、特定の投稿日:に対してコメントをしたい場合は、この設定を変更しなくてもコメントをすることができます。

これについては次のセクションで説明する。

特定のページや投稿日: コメントするのを無効化する

初期設定では、コメントはすべてオフになっています。

しかし、WordPressでは、個々のページや投稿でコメントを有効化したり無効化したりすることができます。

左サイドバーから「ページ」「すべてのページ」を選択します。次のページで、コメントを有効化または無効化したいページのタイトルにマウスカーソルをオーバーし、編集リンクをクリックしてください。

WordPress Page edit option

ページの右上に、縦に3つの点のアイコンがあります。それをクリックしてドロップダウンメニューを開き、オプションをクリックしてください。

ポップアップ・ボックスが開きますので、ここでディスカッション・ボックスが有効化されていることを確認してください。

Page document options

このモーダルボックスを閉じると、エディターの右側にディスカッションのメタ情報が表示されます。

表示されない場合は、必ず「ドキュメント」タブをクリックして表示してください。

Discussion meta box

ここで、コメントを許可するボックスのチェックを外して、このページのコメントを無効化し、更新をクリックして変更を保存します。

一方、選択的にコメントを有効化したい場合は、特定のページだけ有効化するボックスにチェックを入れればよい。

同じ手順で、個々の投稿やその他のカスタム投稿タイプのコメントをオフにすることができます。

一括でページや投稿日: にコメントするのを無効化する。

公開する投稿やページすべてについて、個別にコメントすることなく無効化したいですか?プラグインを使わなくてもできます。

まず、「投稿」→「すべての投稿」ですべての投稿を見ることができます。

次の投稿をすべて選択し、一括操作ドロップダウンボックスから編集を選択し、適用をクリックします。

Edit Posts in bulk

選択したすべての投稿に対して、投稿者名の変更やコメントをオフにするなどの一括操作ができるようになります。

コメントするドロップダウンボックスから「許可しない」を選択し、更新ボタンをクリックします。これで選択した投稿日:すべてコメントすることが無効化されます。

Disable comments on posts in bulk

同じ手順でページのコメントをオフにすることができます。

WordPressのコメントをすべて削除する

上記の方法は投稿日やページにコメントすることを無効化しますが、WordPressサイトから既存のコメントを削除することはできません。

サイトからすべてのコメントを削除するには、管理画面の左サイドバーから「コメントする」をクリックします。

Delete all WordPress comments

次に、すべてのコメントを選択し、一括操作ドロップダウンボックスから「ゴミ箱内に移動」オプションを選択し、適用をクリックします。これでサイトから既存のコメントがすべて削除されます。

あなたのサイトにたくさんのコメントがある場合、WordPressは1ページに表示できるコメント数が決まっているので、このステップを何度も繰り返す必要があります。

メディアページのコメント無効化

メディア添付ファイルページのコメントを無効化したい場合、2つの方法がある。

上で説明した方法に従って、個々のメディア添付ファイルのコメントを手動で無効化することもできますが、これは本当に時間がかかります。

コメントを一括無効化する簡単な方法は、コード・スニペットを使うことです。上級ユーザーであれば、テーマのfunctions.phpファイルに以下のコードを貼り付けることができます。コアファイルを編集してWordPressサイトを壊してしまう可能性があるため、この方法はお勧めしません。

function filter_media_comment_status( $open, $post_id ) {
    $post = get_post( $post_id );
    if( $post->post_type == 'attachment' ) {
        return false;
    }
    return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );

WordPressサイトにコードを追加する最もシンプルで簡単な方法であるWPCodeを使用することをお勧めします。

無料のWPCodeプラグインをインストールして有効化するだけです。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

有効化したら、WordPressダッシュボードのCode Snippetsにアクセスします。Add Your Custom Code (New Snippet)」にマウスオーバーし、「Use Snippet」ボタンをクリックします。

WPCode Add new Snippet

次に、「カスタム・スニペットの作成」画面が表示されます。

ここで、スニペットに「Disable Comments on Media Pages」などのタイトルを付け、上記のコードを「Code Preview」エリアに貼り付けます。

WPCode disabling all comments on media

注意:「コードタイプ」のドロップダウンメニューから「PHPスニペット」を選択し、スイッチを「有効化」に切り替えていることを本当に〜してもよいですか?

あとは「スニペットを保存」ボタンを押すだけで、あなたのサイトにコードが反映されます。

プラグインを使って簡単な方法でWordPressのコメントを無効化する

手動でコメントを無効化したくない場合は、クリックするだけでコメント無効化プラグインを使用することができます。

WordPressサイト上のあらゆる場所でコメントを完全に無効化することができます。投稿日、ページ、メディアなどの特定の投稿タイプで無効化することもできます。また、コメントフォームを削除し、既存のコメントを表示しないようにすることもできます。

Disable Comments

まず最初に行う必要があるのは、コメント無効化プラグインをインストールして有効化することです。詳しい手順はWordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

プラグインを有効化した後、管理画面の左サイドバーからSettingsDisable Commentsにアクセスしてください。

Everywhere」オプションを選択すると、WordPressサイト全体のコメントを無効化することができます。プラグインはWordPress管理エリアからコメントメニュー項目も削除します。

2つ目のオプション「特定の投稿タイプで」を設定すると、投稿日、ページ、メディアに対するコメントを選択的に無効化することができます。

Disable Comments settings

例えば、メディア添付ファイルからコメントだけを削除したい場合、「特定の投稿タイプで」ラジオボタンを選択し、メディアチェックボックスをチェックします。

WordPressページのコメントだけをオフにしたい場合も同じようにできます。プラグインを使うのがWordPressページのコメントを無効化する最も簡単な方法です。

完了したら、Save Changesをクリックすれば完了です。

WordPressで「コメントは終了しました」を削除する

WordPressテーマがコメント状態を適切にチェックしていない場合、コメントフォームや既存のコメントが表示されたり、「コメントは終了しました」というメッセージが表示されたりすることがあります。

これは標準に準拠した方法ではないので、テーマ開発者に修正を依頼することができます。

また、以下の手順に従って、自分で修理することもできます。

まず、FTPクライアントまたはWordPressホスティングコントロールパネルのファイルマネージャを使用してWordPressサイトに接続します。次に、/wp-content/themes/フォルダにある現在のテーマフォルダに移動します。

テーマフォルダーの中にあるcomments.phpというファイルを探し、そのファイルを右クリックしてcomments_old.phpにリネームしてください。

Rename comments php file

次に、FTPクライアントの右パネルで右クリックし、新規ファイル作成オプションを選択する必要があります。

そして、新規ファイル名をcomments.phpとし、「OK」ボタンをクリックします。

Create a new comments file

このトリックは、WordPressテーマの空のコメントテンプレートとして機能するだけなので、コメントやコメント関連のメッセージは表示されません。

WordPressテーマにcomments.phpファイルがない場合は、テーマ開発者にどのファイルを編集する必要があるか尋ねる必要があります。

特典:スパム対策テクニック

スパムやリンクビルダーからサイトを守るためだけにWordPressのコメントを無効化するのであれば、以下のテクニックを使ってスパムと戦うことをお勧めします。

アキズメット

Akismet WordPress Plugin

Akismetは、スパムコメントに対処するための最良のプラグインの一つである。一番の特徴は、WordPressチームによってビルトインされたことです。

このプラグインは、あなたのサイトの各コメントをチェックし、それがスパムかどうかを検証します。詳しくはAkismetプラグインのガイドをご覧ください。

閉会のコメント

一定期間後にコメントを閉じることができることをご存知ですか?

Close comments after a specific period

設定ディスカッションに移動し、”14日以上前の投稿のコメントを自動的に閉じる “にチェックを入れる。

これにより、コメントフォームは14日後に自動的に閉じられます。ニーズに応じて日数を変更することもできます。

通常、スパマーは過去の投稿をターゲットにするので、何人かのユーザーはこの設定を180日に変更し、スパムを大幅に減らしている。

アンチスパムビー付きハニーポット

WPBeginnerでは、Akismetと一緒に動作し、サイト上のコメントスパムを大幅に削減するAntispam Beeという2つ目のプラグインを追加すると便利であることがわかりました。

目に見えないハニーポットを追加し、スパムボットコメントの99%をブロックします。

コメントする CAPTCHA

コメントフォームにCAPTCHAまたはreCAPTCHAを追加することはユーザーフレンドリーではありませんが、あなたのサイトをスパマーから守るのに役立ちます。

CAPTCHA 4WPプラグインを使って、コメントフォームの送信ボタンの直前にreCaptchaを追加することができます。

サイトURLフォームフィールドの削除

リンクビルダーやスパマーに対処するもう一つの方法は、コメントフォームからサイトのURLフィールドを削除することです。多くのスパムコメントは、ボットや単に自分のサイトへのリンクを探しているユーザーからのものだ。

この目的のために、Comment Link Remove と Other Comment Toolを使用することもできます。このプラグインを使えば、個別コードを一行も触ることなく、コメントフォームからサイトのURLフィールドを削除することができます。素晴らしいと思いませんか?

悪質IPのブロック

また、WordPressサイトへのアクセスから悪質なIPアドレスをブロックすることもできます。これにより、スパマーやハッキング攻撃をブロックすることができます。

そのためには、WordPressでIPアドレスをブロックする方法をご覧ください。

この詳細なガイドが、プラグインを使用した場合と使用しない場合のWordPressでコメントを完全に無効化する方法を理解するのに役立てば幸いです。究極のWordPressセキュリティガイド、またはビジネスサイトに最適なプラグインとツールの専門家による比較もご覧ください。

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.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 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

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

  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. Jiří Vaněk says

    Is it possible to ban comments only on a certain category or tag? For example, if I have a category on the website under which there will be articles and I don’t want comments there. Can individual categories or tags be banned this way?

    • WPBeginner Support says

      We do not have a simple way at the moment but we will be sure to share if we find an easy method we would recommend :)

      管理者

      • Jiří Vaněk says

        Thank you for answer. Alternatively, I will keep an eye on your articles to see if any possibility appears over time. It’s great that you then retroactively update older articles as well.

  3. Bradley Maravalli says

    Additional PHP code on how to get rid of the comment icon within the admin bar.

    // Remove comments icon from the admin bar
    add_action( ‘wp_before_admin_bar_render’, function () {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu(‘comments’);
    });

  4. Shawn Bourque says

    Excellent article, thank you. Exactly what I was looking for, and installing the WPCode plugin then following the steps did precisely what I was trying to do. Thanks again!

  5. Steve says

    Thanks for the video. Turning off comments in bulk is not working for me. I followed the steps and it shows, but I keep getting comments. Any suggestions?

    • WPBeginner Support says

      You would want to check where the comments are on your site and see if the comments settings for the specific post/page that they are being added to is not set to disable comments.

      管理者

      • Steve says

        Ok, but the point of the video is to turn off comments globally. That is what I am trying to accomplish. I don’t want anymore comments on my site. Any suggestions?

        • WPBeginner Support says

          Correct, following our guide you should no longer have any comments. If you are still receiving comments then you would want to check the specific page/post you are receiving comments on in case that specific page has settings that would override the global settings.

          This could happen if you missed the page in the bulk edit option or if you accidentally changed the settings when editing that post or page.

  6. Elliot Jolesch says

    Excellent article, and provided me with several options.

    Why would or should I use Akismet instead of Disable Comments?

    The site in question has been designed purely as a “yellow page” display ad, with some text and images of work done.

    • WPBeginner Support says

      Akismet is a tool to help reduce spam if you want to keep the comments available to your users instead of completely closing them.

      管理者

  7. Mr. Tom says

    Great ways and thank you. But, how we should do to prevent someone that they are trying to insert link on comment body with html tag and css modification for color?

    • WPBeginner Support says

      You would want to check with the support for your specific theme if that is not hidden when comments are disabled.

      管理者

    • WPBeginner Support says

      You may have another setting for the specific post overriding or a plugin conflict may be adding the comment area.

      管理者

    • WPBeginner Support says

      On the product page when you are editing it in the admin area of your site there would be the option to disable comments.

      管理者

  8. Mario Noliya says

    I have disabled comment from setting>discussion but still comment is visible on previous posts. how can i remove these on previous post or what is the manual process to remove these comments

    • WPBeginner Support says

      You would either want to use the plugin or manually update the old posts and pages to disable the comments.

      管理者

  9. Engela Edwards says

    Thank you. Your directions and screen shots were very clear and easy to follow. I am grateful for your help.

  10. Harry says

    The comment section/box is a form. You just need to disable it. You can do this through Appearance > Customization > Additional CSS. Just right-click and inspect your comment box to find its id or class (you actually need to find the id or class of its correct parent div). Then you disable like this:

    #idname { display: none; }

    Evidently, “idname” is the name of the correct id you’ve found.

    For example, if you inspect this very comment box, you’ll see that it’s a element and it has a element as a parent. Then if you go up you see this p element is a descendant of a form, which is a child of a div with a “respond” id. If you hide this div, you’ll see that this comment section disappears.

    • WPBeginner Support says

      While this is technically an option if none of the other options work, it does not remove the comment form it only hides it which means it can still be found by spam tools that crawl pages for the comments section.

      管理者

  11. robrt smith says

    I think employing a plugin was an honest idea if your website has many posts and much of latest ones coming daily except for a little blog or sites, it are often done manually.

    • WPBeginner Support says

      You’re correct, if you’re just starting and never want comments then you can do this manually. The plugin is mainly for if removing comments was decided later :)

      管理者

  12. M S says

    Thank you for a very clear and easy to follow tutorial.
    My only question however would be, how to I stop the words ‘no comment’ appearing next to each post?
    Thank you.
    M.

    • WPBeginner Support says

      It would depend on where this is located. If you reach out to your theme’s support they should be able to let you know what options they have available.

      管理者

  13. Manish Sharma says

    I think using a plugin was a good idea if your website has lots of posts and lots of new ones coming daily but for a small blog or sites, it can be done manually.

    • WPBeginner Support says

      That is another option, the plugin is to ensure someone does not forget to disable the comments on a post

      管理者

  14. Alice Elliott says

    Why you should be encouraging people to close or disallow comments on their blogs and websites beats me! This may be necessary for pages, but certainly not for posts! We should be encouraging commenting as much as possible, and educate them in spam moderation and how to overcome trolling behaviour. Even the simple ability to close comments after a number of days will keep the spammers down to a minimum. But closing comments completely is an absolute no-no.

    I note you don’t allow URLs with your commenting – so I will not be benefiting from this comment in any way apart from expressing my disgust!

    • WPBeginner Support says

      It is a personal preference for if someone should use comments. If someone lacks the time or does not want to have comments on their site, this is an option for them. This guide is to show them how to do it, not recommending it for every site :)

      管理者

    • Manish Sharma says

      I don’t want visitors to comment on my site even on my posts.
      Imagine a job posting site… you probably don’t want to see comments below every job post but for a blog like wpbeginner comment makes sense.

      It depends on the type of website. and…

      Links in comments generate lots of spam sometimes even they are nofollow some people or bots just want to post a link in the comment for improving their SEO rankings.

    • Dave says

      Alice, The majority of my clients are corporations using WordPress as a CMS, oftentimes using Posts for a News section or the like. They have no interest in engaging readers via a comment section. That’s what they use Facebook and Twitter for, and it’s why they publish their WordPress content to those platforms. It only makes sense to shut down the commenting feature completely.

      Not every WordPress site is a personal blog.

返信を残す

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