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 →
GridPal PRO WordPress Theme

GridPal PRO

If you like the GridPal Free WordPress Theme, then you will love the premium version. GridPal PRO version has color...

$25.00
BoxWP PRO WordPress Theme

BoxWP PRO

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

$25.00
PureMag PRO WordPress Theme

PureMag PRO

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

$25.00
GridFlex PRO WordPress Theme

GridFlex PRO

If you have used GridFlex Free WordPress Theme, then you will love the premium version. GridFlex PRO version has color...

$25.00
RapidWP PRO WordPress Theme

RapidWP PRO

Did you try RapidWP Free WordPress Theme?, Then you will love the premium version. RapidWP PRO is an improved, more...

$25.00
Simple Grid PRO WordPress Theme

Simple Grid PRO

You'll be pleased with the Simple Grid PRO WordPress theme if you have tried the free version. It is a...

$25.00
BestWP PRO WordPress Theme

BestWP PRO

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

$25.00
ElegantWP PRO WordPress Theme

ElegantWP PRO

If you like ElegantWP free WordPress Theme, you will love the premium version. ElegantWP 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.