Disable Comments In WordPress | Easy Guide

Photo of author
Written By Charlie Giles

Devoted WordPress fan behind CodeCraftWP. Sharing years of web expertise to empower your WordPress journey!

Disclosure: This post may contain affiliate links, which means if you click on a link and make a purchase, I may earn a commission at no additional cost to you.

Want to control comments on your WordPress site? Follow this guide to disable comments per post, using plugins, or modifying .htaccess. Easily manage user interactions and improve site performance with these simple steps.

Disable Comments Per Post

Deactivate Comments via Dashboard

If you’ve ever wondered how to keep your blog posts pristine and free from the clutter of comments—perhaps because they’re outdated or no longer relevant—disabling comments per post is a great solution. Imagine having a library where some books are so treasured that only those who truly understand their value are allowed access, while others might be left open for anyone to share their thoughts. Similarly, you can designate certain posts as “sacred” and protected from unwanted comments.

To deactivate comments per post via the dashboard, it’s surprisingly straightforward. Log in to your WordPress admin panel and navigate to the specific post you wish to modify. This is akin to choosing which door you want to keep locked out of a collection of rooms. Once you’ve selected the desired post, locate the “Comments” section towards the bottom.

Here’s where the process becomes a bit more detailed:

Deactivate Comments via Dashboard

  1. Locate the Comments Section: Within your post’s edit screen, scroll down to find the “Discussion” section or tab.
  2. Disable Comments: In this section, you’ll see options like “Allow comments,” “Close comments,” and sometimes even “Re-open comments.” To disable comments for that particular post, select “Close comments.” It’s as simple as flipping a switch!
  3. Save Changes: After making your selection, don’t forget to click the “Update” or “Publish” button at the bottom of the page to save your changes.

By following these steps, you effectively put up a sign that says “No Comments Allowed” on specific posts, ensuring they remain untouched and uncluttered. It’s like setting aside special items in your home—some things are meant for reflection rather than debate.


Disable Comments Using Plugin

When you’re looking for a straightforward way to disable comments on your WordPress posts or pages, using a plugin is often the best choice. Think of plugins like tools in your digital toolkit—each one designed to tackle specific tasks with ease and efficiency.

Choose a Comment Disabling Plugin

Before diving into installation, it’s wise to choose the right plugin for the job. Many popular choices are available, such as Yoast SEO, Akismet, or Disable Comments by WPBeginner. Each has its own strengths. For instance, Yoast SEO is great for optimizing your content overall, including managing comments. On the other hand, a dedicated comment disabling plugin like “Disable Comments” from WPBeginner can be more streamlined and focused on one task.

Install and Activate Plugin

Once you’ve picked out your preferred plugin, installing it is a breeze. Here’s how to do it:
1. Navigate to Your Dashboard: Log into your WordPress admin panel.
2. Go to Plugins Section: In the left sidebar, click on “Plugins” > “Add New”.
3. Search for the Plugin: Use the search bar at the top of the page and type in the name of the plugin you’ve chosen. For example, if you selected “Disable Comments”, type that into the search box.
4. Install the Plugin: After finding it, click on “Install Now” next to the plugin’s title.
5. Activate the Plugin: Once installed, click on “Activate” below the same title.

With your chosen comment disabling plugin now active, you can start customizing settings according to your needs. This might include choosing whether comments are disabled for all posts or just certain ones, and sometimes even setting up notifications if someone tries to leave a comment despite the plugin’s presence.


Modify Functions.php to Disable Comments

Access WordPress Core Files

Sometimes, you might find yourself in a situation where you need to disable comments on specific posts or globally within your WordPress site. One of the more technical yet effective methods is modifying the functions.php file. Before you start editing core files, it’s important to understand that these changes are permanent and could affect other parts of your site if not done carefully.

Add Code to Disable Comments

To disable comments in the functions.php file, follow these steps:

  1. Backup Your Site: Always make sure to back up your website before making any direct edits to core files. This is a crucial step to avoid losing functionality or causing issues that could affect other aspects of your site.
  2. Locate functions.php: Navigate to the root directory of your WordPress installation, where you’ll find the wp-content folder. Inside this folder, locate the themes folder and then the active theme’s folder (e.g., twentytwentytwo). Open the functions.php file in a text editor like Notepad++ or VSCode.
  3. Add Code Snippet: To disable comments globally, you can add a simple code snippet to your functions.php. Here’s an example:

“`php
function wpb_disable_comments() {
return false;
}

add_filter(‘comments_open’, ‘wpb_disable_comments’, 10, 2);
add_filter(‘pings_open’, ‘wpb_disable_comments’, 10, 2);
“`

Save and Test: Save the changes to your functions.php file and refresh your site to ensure that comments are indeed disabled.

By modifying the functions.php file in this way, you’re essentially telling WordPress not to load any comment-related functions, effectively disabling them across your entire site or specific posts/pages as needed. It’s like turning off a light switch—once you disable it, nothing else can turn it on until you manually flip that switch back.

Remember, while modifying core files is powerful, it should be done with caution and only when necessary. If you’re unsure about the impact of these changes or prefer not to edit core files directly, consider using plugins or other methods discussed in previous sections for a safer approach.


Disable Comments with .htaccess

Edit .htaccess File

Imagine you’re cleaning up your website’s code like decluttering a room. One way to do this is by editing the .htaccess file. This file acts as a gatekeeper for your site, controlling how requests are processed and handled. By making some strategic changes here, you can effectively disable comments without needing to touch any posts or plugins.

Add Code for Comment Disabling

Now, let’s dive into the actual steps of adding the code:

  1. Locate Your .htaccess File: This file is typically found in your WordPress root directory. If you’re not sure where it is, check with your hosting provider or navigate to wp-admin and look for the .htaccess file under “Files”.
  2. Backup Your Current .htaccess File: Before making any changes, it’s always a good idea to back up your current .htaccess file. You can do this by copying its contents into a text editor or using an FTP client.
  3. Open the .htaccess File in a Text Editor: Use a plain text editor like Notepad (on Windows) or TextEdit (on Mac) to open and edit the file. Do not use word processors as they might add unwanted formatting that can cause issues.
  4. Add the Disable Comment Code:

  5. You can add a simple directive to block comment submission by adding the following line at the end of your .htaccess file:
    apache
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/wp-comments-post\.php.*
    RewriteRule ^.*$
    – [R=403,L]
  6. This code uses Apache’s mod_rewrite module to redirect any requests to the comment submission page (/wp-comments-post.php) with a 403 Forbidden error, effectively disabling comments.

  7. Save and Upload Your .htaccess File: Once you’ve added the necessary lines of code, save your changes and upload the file back to its original location on your server using an FTP client or through cPanel if available.
  8. Test Your Site: After making these changes, it’s crucial to test your site thoroughly to ensure that comments are indeed disabled without causing any unintended side effects. Navigate to a few comment sections to see if they work as expected.

By following these steps, you can efficiently disable comments on your WordPress site using the .htaccess file, providing a cleaner and more streamlined experience for both visitors and yourself!

Leave a Comment