Comments made sense for the early blogosphere. For the vast majority of modern WordPress sites, business sites, portfolios, landing pages, documentation sites, SaaS marketing sites, and e-commerce stores, they’re an unused feature that adds spam risk, maintenance overhead, and unnecessary UI complexity. WordPress doesn’t make it easy to turn comments off completely through the admin settings alone; the options exist but they’re spread across multiple screens and don’t fully remove the comment infrastructure from the admin interface.
This snippet takes a thorough approach, disabling comments at every level: closing them on existing content, removing support from post types, and cleaning up all comment-related admin UI.
The Code
Add this to your functions.php or a site-specific plugin. Each block addresses a different surface area of the comment system.
Closing Comments and Pings
The comments_open and pings_open filters control whether new comments and trackbacks can be submitted. Setting both to __return_false at priority 20, higher than WordPress’s default, closes them on all content regardless of per-post settings. The comments_array filter returns an empty array for any request for existing comments, effectively hiding all previously approved comments from the front end.
Removing Comment Support from Post Types
The init hook loops through every registered post type and calls remove_post_type_support() for both comments and trackbacks. This removes the comment and discussion meta boxes from post edit screens and prevents the comment count from appearing in the posts list table. It applies to all post types, posts, pages, and any custom post types, so no post type retains comment functionality.
Admin UI Cleanup
The remaining blocks remove the Comments item from the main admin menu, the comment notification icon from the admin bar, and the Discussion and Comments meta boxes from post edit screens. After applying this snippet, the WordPress admin should have no visible reference to comments anywhere in the interface.
Existing Comments in the Database
This snippet hides existing comments from the front end and closes comments to new submissions, but it doesn’t delete existing comments from the database. If you want to remove existing comments permanently, that’s a database operation, run DELETE FROM wp_comments; and DELETE FROM wp_commentmeta; in phpMyAdmin after taking a backup. Only do this if you’re certain you want to permanently discard all comment data.
Re-enabling Comments Later
Because the snippet uses filters and actions rather than permanent database changes, removing the snippet from your code immediately restores all comment functionality. No data is lost and no settings are permanently changed, the entire disable is reversible by deleting the code.
// Close comments and trackbacks on all existing posts
add_filter( 'comments_open', '__return_false', 20, 2 );
add_filter( 'pings_open', '__return_false', 20, 2 );
// Hide existing comments on all posts
add_filter( 'comments_array', '__return_empty_array', 20, 2 );
// Remove comment support from all post types
add_action( 'init', function() {
$post_types = get_post_types();
foreach ( $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' );
}
}
} );
// Remove comment-related admin menu items
add_action( 'admin_menu', function() {
remove_menu_page( 'edit-comments.php' );
} );
// Remove comment counts from the admin bar
add_action( 'wp_before_admin_bar_render', function() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'comments' );
} );
// Remove the Discussion meta box from post edit screens
add_action( 'admin_init', function() {
foreach ( get_post_types() as $post_type ) {
remove_meta_box( 'commentstatusdiv', $post_type, 'normal' );
remove_meta_box( 'commentsdiv', $post_type, 'normal' );
}
} );
