How to Completely Disable Comments on WordPress

You can completely disable comments on your WordPress site by using the code below. It will get rid of comments on both the front end and the back end, so you won't have to deal with comments on WordPress. It's great for developers and site owners who want a clean site with few distractions.

Add the below code to the functions.php file of your active theme:

/* Function to disable comments throughout the site */
function themesdna_disable_comments_admin_init() {
    /* Redirect any user trying to access comments page */
    global $pagenow;
    
    if ($pagenow === 'edit-comments.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');
        }
    }
}

/* Function to remove comments page in menu */
function themesdna_disable_comments_menu_page() {
    remove_menu_page('edit-comments.php');
}

/* Function to remove comments links from admin bar */
function themesdna_disable_comments_admin_bar() {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
}

/* Hook the function to the admin_init action */
add_action('admin_init', 'themesdna_disable_comments_admin_init');

/* Hook the function to remove comments page in menu */
add_action('admin_menu', 'themesdna_disable_comments_menu_page');

/* Hook the function to the init action */
add_action('init', 'themesdna_disable_comments_admin_bar');

/* 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);

Our WordPress Themes

Below are some of our premium WordPress themes. View all our free and premium WordPress themes →
FineWP PRO WordPress Theme

FineWP PRO

If you like free version of FineWP WordPress Theme, you will love the premium version. FineWP PRO is an improved...

$25.00
GridBone PRO WordPress Theme

GridBone PRO

$25.00
EasyWP PRO WordPress Theme

EasyWP PRO

If you like EasyWP free WordPress Theme, you will love the premium version. EasyWP PRO is an user friendly, HTML5/CSS3...

$25.00
BoldWP PRO WordPress Theme

BoldWP PRO

If you have tried BoldWP Free WordPress Theme, then you will love the premium version. BoldWP PRO is an more...

$25.00
GridMode PRO WordPress Theme

GridMode PRO

Are you using the GridMode free WordPress Theme and looking for more advanced features? GridMode PRO theme is developed for...

$25.00
CleanWP PRO WordPress Theme

CleanWP PRO

If you like CleanWP free WordPress Theme, you will love the CleanWP PRO version. The premium version of CleanWP WordPress...

$25.00
MagPal PRO WordPress Theme

MagPal PRO

$25.00
FreshWP PRO WordPress Theme

FreshWP PRO

If you like FreshWP free WordPress Theme, you will love the premium version. FreshWP PRO is very user friendly, feature-rich,...

$25.00

Can't you choose a single theme? Purchase All Themes for $75.

Save money with our low, one-time price for access to all of our 56 WordPress themes.