WordPress – How to disable comments for new/existing posts and pages

Here’s four options for disabling comments in WordPress.

Please note – any existing comments may still be displayed, depending on how your theme is configured. You may need to delete existing comments to completely remove the comments section from pages and posts.

Option 1: Disable comments for all posts and pages (new and exists) using PHP code

The following code will disable comments for all posts and pages – this includes new and existing.

I highly recommend any customisations are placed into a custom plugin (NOT your theme’s functions.php file) – this way you can easily enable/disable the customisations and keep them when you update or replace your theme.

See How to create a WordPress plugin for your custom functions for how to do this.

add_filter( 'comments_open', '__return_false', 10, 2 );

Note: if you’re using a multi-site WordPress install, you will need to do this in a mu-plugin (must-use plugin). See WordPress – How to create a “Must-Use” plugin.

Option 2: Disable comments for new posts and pages using wp-admin

If you just want to disable comments for new posts and pages – you can change a setting in the wp-admin.

  1. Go to Settings -> Discussion in the wp-admin
  2. and un-tick ‘Allow people to post comments on new articles’
  3. Click ‘Save Changes’

Option 3:  Disable comments for existing posts and pages using wp-admin

The steps below show how to to disable comments for existing posts and pages, leaving newly created posts and pages with comments enabled.

If you don’t feel comfortable with using PHP code you can use a option 2 and option 3 to disable comments for new posts and pages and then manually disable comments for existing.

  1. Open the post or page in the wp-admin
  2. Click on the ‘Screen Options’ tab at the top of the page
  3. Tick ‘Discussion’ if it isn’t already
  4. At the bottom of the page, un-tick ‘Allow comments’
  5. And click ‘Update’ to save the changes

Option 4: Disable comments for posts older than x days

WordPress also provides an option to automatically disable comments for posts older than any number of days — however for some reason it does not apply for pages, only posts.

To automatically disable comments for posts older than 1 day

  1. Go to Settings -> Discussion in the wp-admin
  2. and tick ‘Automatically close comments on articles older than’
  3. and enter the number of days required, e.g. ‘1’
  4. Click ‘Save Changes’