Skip to main content
Login Join
Snippet · PHP

Completely Disable Comments

Shared by Darshit Rajyaguru · May 14, 2026 · @admin_init

27 views
Back to Snippets

Disables comments across entire WordPress site.

add_action( 'admin_init', function() {
	global $pagenow;
	if ( 'edit-comments.php' === $pagenow ) {
		wp_redirect( admin_url() );
		exit;
	}
	remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
	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' );

		}
	}

} );
add_filter( 'comments_open', '__return_false', 20, 2 );
add_filter( 'pings_open', '__return_false', 20, 2 );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments