How to Disable the Comment Section in WordPress Sites to Prevent Spam

 

WordPress websites have a comment section.

Without security measures, spammers will spam the comment section.

 

What is Spam?

Generally, spam refers to any unsolicited user-generated content. Often posted with malicious intent, spam can harm both visitors and the site's search engine reputation.

Unwanted comments can:

1) Eat up valuable disk space
2) Slow down your website
3) Attract more spam bots

In the WordPress ecosystem, spam comments are a widespread issue affecting sites of all sizes, from personal blogs to large e-commerce platforms. To address this problem, many site owners employ various tactics, including comment deactivation.

 


 

Here are 7 Quick Methods to disable the comment section on your WordPress site :

 

Method 1: Disable Comments in WordPress on All Published Posts and Pages

If you want to disable all comments on a website, this method is for you.

Once you apply the following changes, you’ll remove comments on all existing pages and blog posts.

First, you’ll want to delete all of the existing comments under every post and page.

 

1. Navigate to the WordPress admin area.

2. Go to Comments. You’ll see a table detailing every comment you’ve received on your site.

3. Select all the comments by checking the box located on the top left corner of the table.

4. Select Move to Trash from the Bulk Actions drop-down box.

5. Click Apply.

 

 

At this point, you will delete all existing comments on your website. But the WordPress comment form will still be present. It will allow people to post comments underneath your posts and pages.

To fix this for future posts, let’s disable the comment form under every post and page. There are two ways to go about this.

The first option is to use Bulk Actions.

 

1. Navigate to Posts > All Posts. You’ll see a table containing all the posts you have published.

 

2. Select all the posts by checking the box located on the top left corner of the table. Choose Edit from the Bulk Actions drop-down box.

 

3. Find the Comments sections and click Do not allow from the drop-down box.

 
 

4. Finally, select Update to apply the changes to the article settings.

To remove comment forms on every page, navigate to Pages > All Pages and follow the same steps.

 

Note that every page created on WordPress has the comments section turned off by default. If there are comments present on your pages, you probably changed the WordPress comments settings at some point. To fix this, follow the same steps for your pages as well.

The second option is to use the Automatically close comments on posts older than … days setting.

1. Go to Settings > Discussion.

 

2. Under Discussion Settings > Other comment settings, find the Automatically close comments on posts older than … days setting. Fill the field with 0 to turn off comments for all posts.

 

This setting is a bit quicker than the first option (bulk edit). Unfortunately, you can’t apply this technique to pages. If you have comments on your pages and want to disable them in bulk, follow the first option.

 


 

Method 2: Disable WordPress Comments on Future Posts

Although the initial approach can disable comments on your existing WordPress content, it doesn't stop users from commenting on newly published articles. Fortunately, there's a particular setting you can adjust to address this problem.

1. From your WordPress admin area, go to Settings > Discussion.

 

2. Under Default post settings, uncheck the Allow people to submit comments on new posts box.

 

Upon applying this setting, your WordPress site won’t allow people to post comments under future posts.

 


 

Method 3: Disable WordPress Comments on Specific Posts and Pages

For those who still appreciate having comments on certain parts of their site, it's possible to selectively turn off comments on just a few posts or pages.

The steps are very similar to the bulk edit section of Method 1. The difference is that you only need to select several posts and pages instead of all of them.

 

1. Go to your WordPress admin area and navigate to Posts > All Posts.

2. Identify the posts that you want the comments disabled and check their respective boxes.

3. Select Edit from the drop-down box and click Apply.

4. Make sure that you’ve selected the correct posts under Bulk Edit.

5. Choose Do not allow in the drop-down box and click Update.

 

 


 

Method 4: Disable WordPress Comments on an Individual Post or Page

The first three methods are all about disabling comments globally or in bulk. But it’s possible to disable and enable comments on individual posts or pages one by one.

It's important to note that this method can override any global comment settings you've established. This approach offers greater control over your WordPress comment sections and is particularly useful when you need to adjust comment settings for just one piece of content.

There are two ways to accomplish this.

The first approach involves using the WordPress post or page editor. The process is relatively similar regardless of whether you're working with the Gutenberg editor or the Classic editor.

 

1. In the panel located on the right, scroll down until you find the Discussion box.

2. Uncheck Allow comments.

3. Save changes by clicking Publish or Update.

 

 

If you use the Gutenberg editor and can’t find the Discussion box, click the three-dotted button located in the top right corner. Go to Preferences > Document settings. Check Discussion, and the option should now appear.

If you use the Classic editor, bring up the Discussion box by selecting Screen Options and checking the Discussion box.

 

The second option is to use the Quick Edit feature that you can find in the Posts or Pages admin menu.

1. Go to Posts > All Posts or Pages > All Pages if you want to make changes to a page instead.

2. Hover over the item title which comments you want to disable and click Quick Edit.

3. Uncheck Allow Comments.

4. Click Update.

 

 


 

Method 5: Disable Comments on Media

Whenever you add images or other media to your website, WordPress creates separate pages for each file. These media pages can get comments, just like your regular posts or pages can. However, most websites don't really need or want people to comment on their media files.

There are two ways to disable comments under media files.

You can disable them individually, similar to how you’d do it for posts and pages in the fourth method.

1. From your WordPress admin area, go to Media > Library.

2. Find a media file and choose Edit.

3. Under Discussion, uncheck Allow comments.

4. Click Update.

 

 

Unfortunately, unlike posts, pages, and custom post types, there’s no way to apply this setting to media files using Bulk Actions. So this option is less feasible for sites with a massive library of media.

The second option lets you quickly disable comments under all media files on your site. To do this, you’ll have to copy and paste a custom code to your theme’s functions.php file.

Before you proceed, keep in mind that incorrectly adding code snippets to themes can damage sites. To be safe, make sure to create a backup of your site so that you can restore it to the previous version in case anything goes wrong. Also, consider creating a child theme that won’t mess with the parent theme’s settings.

 

1. To locate the functions.php file, go to Appearance > Theme Editor.

 

 

2. Select functions.php on the right.

 
 
 

Then, copy and paste the following code snippet to the file:

 
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
 
function disable_media_comment( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open''disable_media_comment'10 , 2 );
function disable_media_comment( $open, $post_id ) { $post = get_post( $post_id ); if( $post->post_type == 'attachment' ) { return false; } return $open; }
add_filter( 'comments_open', 'disable_media_comment', 10 , 2 );
 


4. Click Update File to finalize the changes.

 


 

Method 6: Disable Comments Using a WordPress Plugin

 

If you prefer a quick and easy way to disable comments in WordPress, the Disable Comments plugin could be a good option.

While the manual methods offer more flexibility, they’re undoubtedly more time-consuming, especially if your website has a lot of content and many unwanted comments to take care of.

This plugin allows users to disable all comments with a single click. Alternatively, you can also choose to disable comments on your posts, pages, or media only.

If you own a multi-site network, you’ll be able to disallow comments on multiple websites, too. The Disable Comments plugin also gives you the ability to remove the “Comments” links from the admin menu and admin bar of your WordPress backend altogether.

 

Once you install the WordPress plugin, go to Settings > Disable Comments on your WordPress admin area.

 

 

 

The settings are categorized under two tabs, Disable Comments and Delete Comments. The former removes the comment form, and the latter removes the comments you’ve received on your WordPress site.

Under the Disable Comments settings, you can choose whether you want to turn off WordPress comments Everywhere or On Specific Post Types.

Unlike the manual methods, the settings applied by this plugin can’t be overridden by individual post settings. Therefore, Method 4 won’t work anymore.

If you still want some comments on your site, be sure to select the correct post type or opt for the manual methods instead.

 

 

 

Under the Delete Comments settings, you have three options. Choose Everywhere if you want to delete all comments on your site.

If you want to keep some comments, select On Certain Post Types to choose which comments under which post type you want gone.

Or you can choose to Delete Certain Comment Types if you want a specific WordPress comment removed, for example, those under WooCommerce product reviews.

 

 

 


 

Method 7: Disable Comments via Custom Code

You can disable all comments on your WordPress site by copying and pasting a couple of code snippets to your theme’s page.php and single.php file.

This option is only recommended if you’ve exercised best practices related to editing the source code of WordPress themes, including creating a backup of your site and creating a child theme.

First, try replacing a line of code on your page.php file to turn off comments on all of the pages.

 

1. On the main dashboard, go to Appearance > Theme Editor.

 

2. Select page.php on the right side.

 

3. Next, find the following code in the file:

<?php comments_template( '', true ); ?>

 
 
 

Replace it with this one:

<!-- Begin Comment
<?php comments_template( '', true );
?> End Comment ?
 

 

Click Update File to save the changes.

 

4. Then, replace a line of code in your single.php file to turn off comments on all your posts.

 

Find the following code:

<?php comments_template(); ?>

 

 

 

And replace it with the following:

<!-- Begin Comment
<?php comments_template(); ?>
End Comment ?

 

Finally, select Update File. Now, the comments on all your pages and posts should be disabled.

 

 

Conclusion:

 

Throughout this guide, we've explored seven different ways to turn off comments on your WordPress site.

Whichever approach you choose, we trust this information has empowered you to better manage your website's comment sections. We wish you success in implementing these changes.

 

 

 

  • 0 Pengguna Ditemui Ini Berguna
Adakah jawapan ini membantu?

Artikel berkaitan

php_flag and php_value errors, and how to fix it.

Problem:You are seeing Internal Server Errors in your browser when you view your web site.You...

What is the path to public_html?

The full system path to public_html is:/home/username/public_html'username' is your cPanel username

What to do if your WordPress site is hacked

Why is my site hacked?Why is my site hacked? What should I do now?A web site is usually hacked...

Jika anda pengguna VPS, ini adalah cara mudah menukar DNS Shoppegram secara pukal

Sekiranya anda miliki VPS (atau server), dan ingin pointkan domain anda ke Shoppegram, sila ikut...

What are your DNS Nameserver details?

Please refer to your Welcome email that contains your username and password that you received...