Remove Comments From Specific Posts and Different Categories

Need to remove comments and the comment form on your posts? In this tutorial, i’ll show you how to:

  • disable comments on specific posts
  • remove comments from all posts in a category
  • remove comments from all posts in multiple categories.
  • remove comments from all but one category.
  • remove comments entirely from different themes.

Disable Comments on Specific Posts

If you need to disable comments on specific posts, you can easily disable them on each post manually.

discussion settings

You can also add the i.d’s for each post to an array in a custom function.

Simply replace the numbers in the array with the posts i.d’s you want to remove your comments from and separate them with a comma.

Remove Comments From All Posts In One Category

Remove Comments From All Posts In Multiple Categories

In this case replace the numbers in the array with the i.d’s for each category you want to exclude comments on.

Remove Comments From All But One Category

Replace the category i.d with the i.d for the category you want to allow comments on. This code will disable comments on all posts in all but one category.

Remove Comments Completely From Your Site

If you don’t want any comments on your site ever, you can remove this line of code from your single.php file.

<?php comments_template(); ?>

Remove Comments From Genesis Theme

This code will remove all comments from your entire site.

Plugins for Removing Comments

Not a coder? Lucky for you i’ve searched the WordPress plugin repo and found a plugin which enables you to easily remove comments from your blog posts.

Disable Comments enables you to disable comments on different post types or your entire site.

This plugin is clearly not as flexible as using code and most useful when removing comments for custom post types.

Delete, Remove & Turn Off Comments

If you want to delete comments, here’s a few tips about how to delete comments by date, remove comments in your spam queue and simply turn off comments.


Comments

8 responses to “Remove Comments From Specific Posts and Different Categories”

  1. Did this change after Genesis 2.0? I added the code to remove comments from one specific category and it did not work. 🙁

    1. Brad Dalton Avatar
      Brad Dalton

      Which code did you copy and what did you need it to do?

  2. Anwar Hussain Avatar
    Anwar Hussain

    Hi! This is really nice post. I would like to know one more code for remove comment from all except multiple categories. This is because I have many categories but I want to remove show comment form in two or more categories. I am not sure but can this code works if ( !in_category( ’27’, ’23’,’56’ )

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Anwar

      You need to add an array like this:

      ! in_category( array( 27,23,56 ) ) ) {

      Hope that helps you Anwar

      1. Anwar Hussain Avatar
        Anwar Hussain

        Thanks for the code.. that works. One more question can this code work for single post to show certain things in all post from the categories except multiple categories:

        if ( is_single() && !in_category(array(11,12,13,14,26,4))) { ?>

        1. Brad Dalton Avatar
          Brad Dalton

          You can add an array to the is_single(array(11,12,13,14,26,4))) { conditional tag so comments are removed only from specific posts.

          Did this answer your question or was it something else?

          1. Anwar Hussain Avatar
            Anwar Hussain

            Thanks Dalton for your help..

          2. Brad Dalton Avatar
            Brad Dalton

            No worries Anwar

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.