How to Completely Disable Comments in WordPress (Ultimate Guide)

Understanding Why Disable Comments in WordPress
WordPress comments, by default, are enabled on posts and pages. They are a powerful tool for fostering community and gathering feedback. However, there are various reasons why you might want to disable them completely:
- Spam Prevention: Comments sections often attract spam bots, requiring constant moderation and consuming server resources.
- Website Focus: You might prefer to focus on delivering content without the distraction of user discussions.
- Simplified Management: Managing comments, even legitimate ones, can be time-consuming. Disabling them eliminates this task.
- Legal Compliance: In some regions, displaying user-generated content requires adhering to specific regulations. Disabling comments can simplify compliance.
- Website Aesthetic: Some website designs prioritize a clean, uncluttered look, and comments can detract from that aesthetic.
- Alternative Communication Channels: You might prefer using social media, forums, or other platforms for engaging with your audience.
Whatever your reason, this guide will provide you with a comprehensive overview of methods to completely disable comments in WordPress.
Method 1: Disabling Comments Globally from the WordPress Dashboard
This is the simplest method and the quickest way to disable comments across your entire WordPress website. It will prevent new comments from being posted, but existing comments will remain visible until you delete them.
- Log in to your WordPress Dashboard: Access your WordPress admin area by adding `/wp-admin` to your website’s URL (e.g., `www.yourwebsite.com/wp-admin`).
- Navigate to Settings > Discussion: In the left-hand menu, locate the “Settings” option and click on “Discussion.” This will take you to the Discussion Settings page.
- Disable Default Post Settings: Under the “Default post settings” section, uncheck the box labeled “Allow people to submit comments on new posts.” This will prevent comments from being enabled by default on any new posts you create.
- Disable Comments on Existing Posts (Bulk Edit): Scroll down to the bottom of the Discussion Settings page and click “Save Changes.” Then, navigate to “Posts > All Posts.”
- Select All Posts: Check the box at the top of the post list to select all posts on the current page. If you have multiple pages of posts, you’ll need to repeat this process for each page.
- Edit in Bulk: In the “Bulk actions” dropdown menu, select “Edit” and click “Apply.”
- Change Comments Status: In the bulk edit options, find the “Comments” dropdown menu. Change the setting to “Do not allow.”
- Update Posts: Click the “Update” button to apply the changes to all selected posts. This will disable comments on all of them.
- Disable Comments on Existing Pages (Bulk Edit): Repeat steps 4-8 for your pages. Navigate to “Pages > All Pages” and follow the same bulk editing process.
This method effectively disables comments on both new and existing posts and pages. However, some themes might override these settings. If you’re still seeing comments, try the other methods outlined below.
Method 2: Disabling Comments Using Code (functions.php)
This method involves adding code snippets to your theme’s `functions.php` file. This approach provides more control and can be used to disable comments more comprehensively. **Caution:** Editing the `functions.php` file incorrectly can break your website. It is highly recommended to back up your website before making any changes to this file. Consider using a child theme to avoid losing your changes when the parent theme is updated.
- Access Your Theme’s functions.php File: There are several ways to access your theme’s `functions.php` file:
- WordPress Theme Editor: Navigate to “Appearance > Theme Editor” in your WordPress dashboard. Locate the `functions.php` file in the list of theme files on the right-hand side.
- FTP/SFTP: Use an FTP client (like FileZilla) to connect to your web server. Navigate to the `wp-content/themes/your-theme-name/` directory and locate the `functions.php` file.
- File Manager (cPanel): Access your web hosting account’s cPanel and use the File Manager to navigate to the `wp-content/themes/your-theme-name/` directory and locate the `functions.php` file.
- Add the Following Code Snippets: Paste the following code snippets into your `functions.php` file:
“`php
// Disable comments globally
function disable_comments_globally() {
// Disable comments on the frontend
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);// Remove comment support from post types
function remove_comment_support() {
$post_types = get_post_types();
foreach ($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’);
}
}
}
add_action(‘init’, ‘remove_comment_support’, 100);
}
add_action(‘init’, ‘disable_comments_globally’);// Close comments on media files
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 );// Remove comments from admin menu
function remove_comment_menu() {
remove_menu_page(‘edit-comments.php’);
}
add_action(‘admin_menu’, ‘remove_comment_menu’);// Remove comments from admin bar
function remove_comment_admin_bar( $wp_admin_bar ) {
$wp_admin_bar->remove_node( ‘comments’ );
}
add_action( ‘admin_bar_menu’, ‘remove_comment_admin_bar’, 999 );// Redirect anyone trying to access comments page
function redirect_comments_page() {
global $pagenow;if ($pagenow === ‘edit-comments.php’) {
wp_redirect(admin_url());
exit;
}
}
add_action(‘admin_init’, ‘redirect_comments_page’);
“` - Save the Changes: After adding the code, save the `functions.php` file.
- Test Your Website: Clear your browser cache and visit your website to ensure that comments are disabled on all posts and pages. Also check the admin area to ensure the comments menu is removed.
This code snippet performs several actions:
- It disables comments on the frontend, preventing new comments from being submitted.
- It hides existing comments from being displayed.
- It removes comment support from all post types.
- It closes comments on media files.
- It removes the comments menu from the WordPress admin area.
- It removes the comments icon from the admin bar.
- It redirects users who try to access the comments page in the admin area.
This method provides a more robust solution for disabling comments, as it removes all traces of comments functionality from your website.
Method 3: Disabling Comments Using a WordPress Plugin
Several WordPress plugins can help you disable comments easily without requiring any coding. This is a user-friendly option, especially for beginners.
- Install and Activate a Disable Comments Plugin: Navigate to “Plugins > Add New” in your WordPress dashboard. Search for “Disable Comments” (several options are available; “Disable Comments” by wpDiscuz is a popular choice). Install and activate the plugin.
- Configure the Plugin Settings: After activation, the plugin will usually add a new settings page under “Settings” or a sub-menu under “Tools.” Locate the plugin’s settings page.
- Choose the Scope of Comment Disabling: Most “Disable Comments” plugins offer options to disable comments globally (on all post types) or selectively (on specific post types like posts, pages, or media). Choose the option that best suits your needs.
- Apply the Changes: Save the plugin settings. The plugin will automatically disable comments based on your chosen configuration.
- Verify the Changes: Check your website to ensure that comments are disabled as expected.
Some popular “Disable Comments” plugins include:
- Disable Comments: By wpDiscuz – Offers global and selective comment disabling, including options to remove comments-related menu items and widgets.
- Disable Comments – Remove & Close Comments: A simple plugin that allows you to disable comments globally.
- Comment Disable & Delete: A plugin that allows you to disable comments and also delete existing comments in bulk.
Using a plugin is the easiest and safest method for beginners. It provides a user-friendly interface for managing comment settings without requiring any coding knowledge.
Method 4: Disabling Comments on Media Attachments
Media attachments (images, videos, etc.) in WordPress can also have comments enabled. If you want to completely disable comments, you need to address this as well.
- Using the functions.php File (as described in Method 2): The code snippet provided in Method 2 already includes code to disable comments on media attachments. The following code snippet achieves this:
“`php
// Close comments on media files
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 );
“` - Using a Plugin: Some “Disable Comments” plugins offer specific options to disable comments on media attachments. Check the plugin’s settings to see if this option is available.
By implementing one of these methods, you can ensure that comments are disabled on all media attachments, providing a consistent experience across your website.
Method 5: Deleting Existing Comments in Bulk
Disabling comments will prevent new comments from being posted, but it won’t automatically delete existing comments. If you want to remove all existing comments from your WordPress database, you can use one of the following methods:
- Using the WordPress Dashboard (Bulk Delete):
- Navigate to “Comments” in your WordPress dashboard.
- Select all comments on the current page by checking the box at the top of the comment list.
- In the “Bulk actions” dropdown menu, select “Move to Trash” and click “Apply.”
- Navigate to the “Trash” tab.
- Select all comments in the Trash and choose “Delete Permanently” from the “Bulk actions” dropdown menu, then click “Apply.”
- Repeat this process for all pages of comments. If you have a large number of comments, this method can be time-consuming.
- Using a Plugin:
- Install a plugin like “Delete All Comments” or “Comment Disable & Delete.”
- Activate the plugin and navigate to its settings page.
- Follow the plugin’s instructions to delete all comments in bulk.
- Be cautious when using these plugins, as the deletion process is irreversible. It’s recommended to back up your database before deleting comments.
- Using phpMyAdmin (Advanced):
- Access your web hosting account’s cPanel and open phpMyAdmin.
- Select your WordPress database.
- Run the following SQL query to delete all comments: `TRUNCATE wp_comments;`
- Run the following SQL query to reset the auto-increment value for the `wp_comments` table: `ALTER TABLE wp_comments AUTO_INCREMENT = 1;`
- **Caution:** This method is advanced and should only be used if you are comfortable working with databases. Make a backup of your database before running any SQL queries.
Deleting existing comments is crucial if you want to completely remove all traces of the comments feature from your website.
Troubleshooting Comment Disabling Issues
If you’ve followed the steps above and comments are still appearing on your website, here are some troubleshooting tips:
- Theme Overrides: Some themes may override the default WordPress comment settings. Check your theme’s documentation or contact the theme developer for assistance.
- Plugin Conflicts: Deactivate all plugins except for the “Disable Comments” plugin (if you’re using one). If the issue is resolved, reactivate your plugins one by one to identify the conflicting plugin.
- Caching: Clear your website’s cache and your browser’s cache to ensure that you’re seeing the latest version of your website.
- Database Issues: In rare cases, database corruption can cause comment settings to be ignored. Consider using a database repair plugin or contacting your web hosting provider for assistance.
- Check Individual Posts/Pages: While you’ve disabled comments globally, double-check individual posts and pages to ensure that the “Allow Comments” checkbox is unchecked. If it is checked on an individual post/page, it will override the global setting.
By carefully troubleshooting these potential issues, you should be able to completely disable comments on your WordPress website.