Completely Disable Comments in WordPress
Home » WordPress » How to Completely Disable Comments in WordPress

How to Completely Disable Comments in WordPress

Disabling comments on a WordPress site can be essential for websites that want to minimize spam, reduce moderation workload, or simply focus on publishing content without user feedback.

Whether you’re managing a business site, portfolio, or personal blog, turning off comments can streamline site management and improve performance.

Reasons to Disable Comments in WordPress

Disabling comments helps control spam and maintain the quality of content on your site. It can also be crucial for compliance with data protection regulations by reducing the collection of user data.

Methods to Disable Comments

You can disable comments in WordPress either by using the built-in settings or by employing plugins or custom code for more comprehensive control.

Using WordPress Settings

The default WordPress settings offer an easy way to disable comments on new posts, but they do not retroactively apply to existing content.

  1. Go to Settings > Discussion in your WordPress dashboard.
  2. Uncheck “Allow people to submit comments on new posts.”
  3. Save your changes.

This method stops comments on all future posts but does not close comments on existing posts.

Disabling Comments on Existing Content

To disable comments on existing posts and pages, you will need to edit each post or use bulk edit.

  1. Navigate to Posts > All Posts (or Pages > All Pages).
  2. Click on the checkbox at the top of the list to select all items on the current page.
  3. Select “Edit” from the “Bulk Actions” dropdown menu, then click “Apply.”
  4. Set “Comments” to “Do not allow,” and then click “Update.”

Repeat this process for all pages of posts or pages if your site has more content than fits on one page.

How to Completely Disable Comments in WordPress Using Plugins or Custom Code

For a more streamlined and automatic approach, especially if you have numerous posts, using a plugin or adding custom code can be more efficient.

Completely Disable Comments Using a Plugin

Plugins like “Disable Comments” allow you to globally disable comments across all post types and remove all comment-related fields and links.

  1. Install and activate the “Disable Comments” plugin from the WordPress plugin repository.
  2. Navigate to Settings > Disable Comments.
  3. Choose whether to disable comments everywhere or on specific post types, and apply your changes.

This plugin method is comprehensive and also handles comments on media files, which are often overlooked in manual settings.

Adding Custom Code

If you prefer not to use a plugin, you can add custom code to your site using a site-specific plugin like “Code Snippets.”

  1. Install the “Code Snippets” plugin from the WordPress plugin repository.
  2. Activate the plugin and go to Snippets > Add New.
  3. Paste the following code into the snippet area:
    add_action('admin_init', function () {
        // Redirect any user trying to access comments page
        global $pagenow;
        
        if ($pagenow === 'edit-comments.php') {
            wp_safe_redirect(admin_url());
            exit;
        }
        // Remove comments metabox from dashboard
        remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
        // Disable support for comments and trackbacks in post types
        foreach (get_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');
            }
        }
    });
    // Close comments on the front-end
    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, 2);
    // Remove comments page in menu
    add_action('admin_menu', function () {
        remove_menu_page('edit-comments.php');
    });
    // Remove comments links from admin bar
    add_action('admin_bar_menu', function () {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }, 0);
  1. Name your snippet (e.g., “Disable Comments Site-Wide”), save it, and activate it.

This custom code snippet effectively removes all aspects of commenting from your WordPress site, ensuring a completely comment-free environment.

Wrapping Up

Choosing the right method to disable comments depends on your specific needs and technical comfort level. Each method provided offers a secure way to eliminate comments from your WordPress site, simplifying management and enhancing performance.

Similar Posts