How to Completely Disable Comments in WordPress

How to Completely Disable Comments in WordPress

In this article, you will learn how to completely disable WordPress comments site-wide just using a simple code snippet.

In this article, you will learn how to completely disable WordPress comments site-wide – suitable when removing legacy, unused comment sections or relying on alternative discussion platforms.

The multistep approach involves shutting off core settings, hiding UI elements, installing plugins to prevent further commenting capability, and cleaning database clutter from past comments.

When executed precisely, our methodology completely eradicates vestigial comment infrastructure that may bog down modern WordPress installations.

Editor's Note:

Ensure a child theme first for safe WordPress customization. Our child theme tutorial details creating one so edits don’t impact parent themes. Changes survive parent theme updates using this method.

Insert the Code into function.php File or Use Code Snippet Plugin

The following snippet will disable comments for all post types, in the admin and the frontend. So the admin interface in the admin area.

add_action('admin_init', function () {
    // Redirect any user trying to access comments page
    global $pagenow;
    if ($pagenow === 'edit-comments.php') {

    // 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 comments links from admin bar
add_action('admin_bar_menu', function () {
    remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}, 0);

Thereafter, comments are fully disabled site-wide – ideal for centralized discussions or comment-free sites. Our precise methodology eliminates legacy bloat while allowing modern engagement integration. With unwanted clutter eradicated, focus shifts to implementing refined interactions.

The WordPress Learning Hub

Related Posts