How To Disable WordPress Comments

Comments are a great way to engage your readers, but moderating them can be a pain. On top of that all kinds of bots will try to spam your WordPress site comment area and get their links and ads showing up on your site. To battle this issue you can add some form of spam protection but the best way is to disable comments completely and here’s how to.

Disable comments on future posts only

To disable comments on future posts only head on to “Settings > Discussion” and remove the select from “Allow people to submit comments on new posts”. This will allow users to comment on old posts that have commenting enabled but will remove the ability to comment on new posts on your page.

Disable comments on specific post or page

If you wish to disable comments on specific posts just head on to “Posts”. Hover your mouse on top of the post you wish to edit and click “Quick edit”. On “Quick edit” you can see the setting “Allow Comments”. Remove the select and “Update” and the commenting will be disable on this specific post.

Disable comments on specific posts

The same setting can be found when you open any post from the “Post” sidebar settings under “Discussions”. Remove the select and press “Publish” or “Update” and comment will be disabled on the post.

Disable comments in bulk

If you wish to disable comments in bulk, simply head on to “Posts”. Select the posts you want to edit and select “Edit” from the “Bulk actions” and press “Apply”.

After this you can quickly disable comments on these pots by selecting the “Comments”, changing it to “Do not allow” and pressing Update”.

This will disable comments in bulk from all the posts you have selected.

Disable WordPress comments in bulk

Disable WordPress comments and remove comments from WordPress admin menus

If you wish to disable commenting and remove it from admin as well you can use the following code. The code needs to be added to your functions.php file.

Here’s a list what the code does:

  • Redirect any user trying to access comments page
  • Remove comments metabox from dashboard
  • Disable support for comments and trackbacks in post types
  • Closes comments on front-end
  • Hides existing comments
  • Removes comments page and options page in menu
  • Removes comments link from admin bar
/**
 *
 * Disable comments and remove comments from all admin menus
 * Tested up to WordPress 5.8.2
 **/

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    
    if ($pagenow === 'edit-comments.php' || $pagenow === 'options-discussion.php') {
        wp_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 and option page in menu 
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
    remove_submenu_page('options-general.php', 'options-discussion.php');
});

// Remove comments links from admin bar
add_action('add_admin_bar_menus', function () {
    remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
});

If you liked our post, remember to share it forward and comment below if it helped you.

Similar Posts

Leave a Reply

Your email address will not be published.