How can I disable comments in WordPress?

This one.com guide will assist you in turning off comments on your WordPress website, providing methods for disabling comments on individual posts, pages, or your entire site.


Why disable comments in WordPress?

You may want to turn off comments on specific posts or pages or disable comments on your entire website for various reasons. For example, bloggers may not want comments on certain posts, and small business websites may not need them at all. Disabling comments can also help prevent spam. In WordPress, you can easily turn off comments or remove the comment section entirely.


How to manually disable comments

Please note that directly pasting code snippets into your theme files can easily break your site and is only recommended for advanced users. You can find alternative options in the sections below.

  1. Select your theme's functions.php file with the one.com File Manager.
  2. Click Edit in the pane to the right.
    edit_functions.png
  3. Paste the provided code snippet at the end of the file:
    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('init', function () {
        if (is_admin_bar_showing()) {
            remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
        }
    });
    
  4. Click Save to save your changes.
  5. Done! This snippet redirects users trying to access the comments page, removes comments-related features, and closes comments on the front end.

Disable comments on future posts

If you're starting a new WordPress site, you can easily disable comments on future posts. Follow these steps:

  1. Go to Settings > Discussion in your WP Admin.
  2. Uncheck "Allow people to submit comments on new posts."
    future_commentsOFF.png
  3. Scroll down and click Save Changes to disable comments on future posts.

Disable comments on a specific page or post

By default, comments are disabled on all pages in WordPress. However, you have the freedom to enable or disable them on individual pages and posts.

  1. In your WP Admin, navigate to Pages > All pages.
  2. Hover your mouse over the page title to enable/disable comments.
  3. Click Edit under the desired page or post.
  4. Click on the Settings tab located on the right side of the editor.
  5. Then, find the Discussion box and uncheck "Allow Comments."
    Pagecomments.png
  6. Click on the Update button at the top next to the Settings tab.
Note: If you are unable to see it, you should check whether the Discussion box is enabled or not. On the top-right corner of your page, you will see a three vertical dots icon. Click on it to open a dropdown menu and select Preferences. Then, head to Panels and switch on the Discussion box.

You can follow the same process for turning off comments on individual posts:
WP Admin > Posts > All Posts > Edit.


Disable comments on pages and posts in bulk

Do you want to disable comments on all your published posts and pages at once, without using a plugin? Then follow these steps.

  1. Go to Posts > All Posts in your WP Admin and select the desired posts.
  2. Choose Edit from the Bulk Actions dropdown and click Apply.
  3. Set the comments dropdown to "Do not allow".
  4. Click Update to complete the process.
    wp-comment.png

You can follow the same process for turning off comments on your pages:
WP Admin > Pages > All Pages > Edit.


Delete all WordPress comments

Although disabling comments on your WordPress site will prevent new comments from being added to your posts and pages, it will not remove any existing comments. To delete all the comments from your site, follow these steps:

  1. In your WP Admin, go to the Comments section.
  2. Choose "Move to Bin" from the Bulk Actions dropdown and click Apply.
  3. This process permanently deletes existing comments. If your website has a lot of comments, you may need to repeat this step multiple times since WordPress only displays a certain number of comments per page.
    delete_comments.png

Disable WordPress comments using a plugin (WPCode)

As a last resort, we recommend using a plugin to disable comments, especially if your WordPress site is under attack by spambots. WPCode is a free plugin that can be used for this purpose.

  1. Log in to your WP Admin to install and activate the free WPCode plugin.
  2. Navigate to Code Snippets > Library in your WP Admin.
  3. Search for "completely disable comments" and use the corresponding code snippet by hovering over it.
    WPcode.png
  4. Click Edit snippet and WPCode will open the 'Edit Snippet' page.
  5. Toggle the switch on the right side to Active and click Update
    WPcode2.png
  6. That's it! This action removes all traces of comments from your site.

Related articles:

Was this article helpful?

Can’t find what you are looking for?

Start a chat

It's the quickest way to get in touch, every day of the year.

Give us a call

Available on weekdays from 10am to 2pm (UTC).