1. Home
  2. /
  3. Web Design & Development
  4. /
  5. WordPress
  6. /
  7. How to remove or disable comments on a WordPress website?

How to remove or disable comments on a WordPress website?

How to remove or disable comments on a WordPress website

Introduction

Getting too many annoying email notifications or comments from your wordpress website? Well, there is a way to stop it for good. If your website does not need a comment module. You can easily remove the comments form and restrict your website from sending you annoying spam comment notifications. Follow the steps below to disable the comments on your wordpress website.

Steps to remove comments from WordPress Website

Step 1: Go to your Website’s active theme folder or directory

Step 2: Backup the comments.php file

Step 3: Now, create a new empty comments.php file

Following step 1 to 3, you can stop receiving comments or any kind of comment notifications on your WordPress website.

Below step can be useful in cases where you would like to keep the comments feature on your wordpress website but would not like to receive comments on your attachment urls.

Steps to disable comments on your WordPress website

Edit your themes function.php file and add the below piece of code at the very bottom.

function smart_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', 'smart_filter_media_comment_status', 10 , 2 );

Save the file and you’re done.

Reviews & Ratings Get your stoe online with Shopify in 60 minutes Shop Now