How to disable comments in WordPress without a plugin

Fixes & snippets

24 November 2026

How to disable comments in WordPress without a plugin

The settings-only way, and one tested snippet that switches comments off everywhere for good.

Tested on WordPress 7.1 and Avada 7.16.4, November 2026.

Most business websites don’t need comments, and leaving them on just invites spam. WordPress has no single “turn comments off” switch, so people either install a plugin or turn them off in three different places. Here’s the settings-only way, then a single snippet that switches comments off everywhere, for good.

The settings-only way

If you’d rather not add any code:

  1. Settings > Discussion: untick Allow people to submit comments on new posts and Allow link notifications from other blogs (pingbacks and trackbacks). This only affects posts you create from now on.
  2. Existing posts: go to Posts > All Posts, select all, choose Bulk actions > Edit, set Comments to Do not allow and update. Repeat for pages.
  3. Avada sites: Avada also has its own comment display switches in Avada > Options: Comments in the Blog section (on by default) and the Portfolio section, and Comments on Pages under Extra. Turn those off too, so there’s no empty comments area left in the layout.

That stops new comments, but the Comments menu, the dashboard widget and the comments feed are all still there, and new post types can still have comments switched on.

The snippet: disable comments everywhere

This closes comments and pingbacks on every post type, hides any existing comments, and removes the Comments menu, the dashboard widget, the admin bar link, the comments REST endpoints and the comments feed link.

<?php
/**
 * Disable comments site-wide.
 */

// Close comments and pings everywhere, and hide any existing comments.
add_filter( 'comments_open', '__return_false', 20 );
add_filter( 'pings_open', '__return_false', 20 );
add_filter( 'comments_array', '__return_empty_array', 10 );

// Remove comment support from every post type.
add_action( 'init', function () {
	foreach ( get_post_types() as $type ) {
		if ( post_type_supports( $type, 'comments' ) ) {
			remove_post_type_support( $type, 'comments' );
			remove_post_type_support( $type, 'trackbacks' );
		}
	}
}, 100 );

// Admin: remove the Comments menu, dashboard widget and admin bar link,
// and send anyone who opens the Comments screen back to the dashboard.
add_action( 'admin_menu', function () {
	remove_menu_page( 'edit-comments.php' );
} );
add_action( 'admin_init', function () {
	global $pagenow;
	if ( 'edit-comments.php' === $pagenow ) {
		wp_safe_redirect( admin_url() );
		exit;
	}
	remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
} );
add_action( 'admin_bar_menu', function ( $bar ) {
	$bar->remove_node( 'comments' );
}, 999 );

// Remove the comments REST endpoints and the comments feed link.
add_filter( 'rest_endpoints', function ( $endpoints ) {
	unset( $endpoints['/wp/v2/comments'], $endpoints['/wp/v2/comments/(?P<id>[d]+)'] );
	return $endpoints;
} );
add_filter( 'feed_links_show_comments_feed', '__return_false' );

Where to put it

Pick one of these. Don’t paste it into your theme’s functions.php unless it’s a child theme, because a theme update will wipe it.

  • A must-use plugin (my choice). Save the code as disable-comments.php in wp-content/mu-plugins/ (create the folder if it doesn’t exist). It loads automatically, can’t be switched off by accident, and survives theme changes.
  • A code snippets plugin. Paste it in without the opening <?php line and activate it.
  • A child theme’s functions.php. Fine if you already have a child theme. Paste it without the opening <?php line.

Take a backup first. A typo in PHP can take the site down, and if it does, deleting the file you just added brings it straight back.

How I tested it

On a test post with comments open, WordPress reported comments as open before the snippet was added. With it in place, comments_open() returned false, posts no longer supported comments, a test comment was rejected as “comments closed”, and the comments REST endpoint returned a 404.

What about existing comments?

The snippet hides them everywhere, but they’re still in the database. To delete them for good, go to Comments before adding the snippet (it removes that screen), select all and move them to the bin, then empty it. Or, if you have WP-CLI:

wp comment delete $(wp comment list --format=ids) --force

Back up the database first. Deleted comments can’t be recovered.

Common questions

Will disabling comments affect my SEO?

Not on a business site. It removes the risk of spam links appearing on your pages, which only ever hurts.

Can I turn comments back on later?

Yes. Remove the snippet and comments behave as they did before, with any comments you didn’t delete reappearing.

Do I need a plugin to disable comments?

No. The snippet above does everything the popular plugins do for most sites, without another plugin to keep updated.

Rather someone else did it?

Small jobs like this are included in my WordPress maintenance plans, along with updates, backups and monitoring.

Mark McKeown

Mark McKeown

Freelance WordPress developer in Belfast since 2015: 100+ sites, nearly all in Avada.

Need a hand with this?

Tell me what’s going on with your site. I reply within one working day.

More insights

  • WordPress

    22 Nov 2026

    How much does website maintenance cost in the UK?

    Typical UK prices for website maintenance in 2026, what you should get at each level, and the hidden costs to watch for.

  • Speed

    22 Nov 2026

    How to improve website speed on WordPress

    What actually slows a WordPress site down, the fixes worth doing first, and the old tips that no longer make much difference.

Tell me about your project

New site, redesign, agency build or a fix that can't wait. I reply within one working day.