WP AI Agent
Features Pricing Blog Contact Download Plugin Manage Subscription Get Free Key →

How to Enable or Disable WordPress Comments on Specific Posts

· · 8 min read

Knowing how to enable or disable WordPress comments on specific posts is an essential skill for any site owner who wants precise control over reader engagement, spam prevention, and page performance. Whether you run a blog, a business site, or a news portal, WordPress gives you multiple methods to manage comments at the post level, globally, or even programmatically. This guide walks you through every approach so you can choose the one that fits your workflow best.

Understanding How WordPress Comments Work

Before diving into the how-to steps, it helps to understand the comment system's hierarchy. WordPress manages comments at three levels:

  • Global settings — the default behaviour applied to all new posts, found in Settings > Discussion.
  • Post-level settings — overrides applied to individual posts or pages.
  • Programmatic settings — changes made via PHP, WP-CLI, or database queries for bulk or automated management.

When you change a global setting, it only affects new content created after that change. Existing posts retain whatever setting was active when they were published — unless you update them individually or in bulk. Understanding this distinction prevents a lot of confusion.

Enabling or Disabling Comments on a Single Post

The quickest way to control comments on one specific post is directly inside the post editor. WordPress provides this option in both the Classic Editor and the Block Editor (Gutenberg).

Using the Block Editor (Gutenberg)

  1. Open the WordPress dashboard and navigate to Posts > All Posts.
  2. Click the title of the post you want to edit.
  3. In the post editor, click the Settings icon (the gear icon) in the top-right corner to open the sidebar panel.
  4. Select the Post tab in the sidebar (not the Block tab).
  5. Scroll down until you find the Discussion section. If it is collapsed, click the arrow to expand it.
  6. Check or uncheck the Allow comments checkbox to enable or disable comments respectively.
  7. Click Update or Publish to save your changes.

If you do not see the Discussion panel, it may be hidden. Click the three-dot menu (⋮) in the top-right corner, select Preferences, go to the Panels tab, and make sure Discussion is toggled on.

Using the Classic Editor

  1. Open the post in the Classic Editor.
  2. If you do not see a Discussion meta box below the content area, click Screen Options at the top of the page and check the Discussion box.
  3. Scroll down to the Discussion meta box.
  4. Check or uncheck Allow comments as needed.
  5. Click Update to save.

Bulk Enabling or Disabling Comments on Multiple Posts

If you need to update comments settings on many posts at once, WordPress's bulk edit feature is your best friend. This approach saves significant time compared to editing each post individually.

Using the Posts List Bulk Edit

  1. Go to Posts > All Posts in your WordPress dashboard.
  2. Use the checkboxes on the left to select all posts you want to update. You can also click the checkbox in the header row to select all visible posts, and use the pagination to load more if needed.
  3. Open the Bulk actions dropdown at the top of the list and choose Edit.
  4. Click the Apply button. A bulk editing panel will appear above the post list.
  5. Find the Comments dropdown inside the bulk edit panel.
  6. Select Allow to enable comments or Do not allow to disable them.
  7. Click the Update button to apply the changes to all selected posts.

Tip: Use the category or tag filters at the top of the Posts list to narrow down posts before selecting them for bulk editing. This makes it easy to, for example, disable comments on all posts in a specific category.

Changing the Global Default Comment Setting

If your goal is to disable or enable comments on all future posts by default, adjust the global discussion setting. This does not retroactively change existing posts, but it sets the baseline for everything you create going forward.

Adjusting Discussion Settings

  1. Navigate to Settings > Discussion in the WordPress dashboard.
  2. At the top of the page, find the section labelled Default post settings.
  3. Check or uncheck Allow people to submit comments on new posts.
  4. Scroll to the bottom and click Save Changes.

You can also control additional behaviours here, such as requiring comment approval, enabling comment moderation, and closing comments automatically after a set number of days (for example, 14 or 30 days after publication).

Managing Comments Programmatically with PHP and WP-CLI

For developers or power users managing large sites, programmatic methods offer the most flexibility and speed. You can update comment status on hundreds or thousands of posts with a single command or code snippet.

Using WP-CLI to Disable Comments on All Posts

WP-CLI is the official command-line interface for WordPress. The following command disables comments on every published post by updating the comment_status field in the database:

wp post list --post_status=publish --post_type=post --format=ids | xargs -d ' ' -I % wp post update % --comment_status=closed

To enable comments instead, replace closed with open:

wp post list --post_status=publish --post_type=post --format=ids | xargs -d ' ' -I % wp post update % --comment_status=open

You can also target a specific post by its ID directly:

wp post update 42 --comment_status=closed

Using a PHP Snippet in functions.php

If you want to programmatically disable comments on all posts of a certain type without touching the database directly, you can add a filter in your theme's functions.php file or in a custom plugin:

// Disable comments on all posts
add_filter( 'comments_open', function( $open, $post_id ) {
    $post = get_post( $post_id );
    if ( $post && $post->post_type === 'post' ) {
        return false;
    }
    return $open;
}, 10, 2 );

// Also hide the comments count from appearing
add_filter( 'get_comments_number', function( $count, $post_id ) {
    $post = get_post( $post_id );
    if ( $post && $post->post_type === 'post' ) {
        return 0;
    }
    return $count;
}, 10, 2 );

Important: Always back up your site before editing functions.php. A syntax error in this file can break your site. Consider using a child theme or a code snippets plugin to add custom PHP safely.

Disabling Comments Site-Wide via functions.php

To close comments entirely across every post type and page, you can use a broader approach:

// Disable support for comments and trackbacks in post types
function disable_comments_post_types_support() {
    $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' );
        }
    }
}
add_action( 'admin_init', 'disable_comments_post_types_support' );

Troubleshooting Common Comment Control Issues

Sometimes the steps above may not produce the expected result. Here are the most common issues and how to resolve them.

Comments Still Showing After Disabling

If you disabled comments on a post but existing comments are still visible, remember that disabling comments only prevents new submissions. To hide existing comments, you need to either delete them, unapprove them, or use a CSS or PHP-based approach to hide the comments section from the front end.

Discussion Panel Not Visible in the Block Editor

As mentioned earlier, the Discussion panel can be hidden. Go to the editor's Preferences (three-dot menu > Preferences > Panels) and enable the Discussion panel. If the panel is still missing, a plugin may be overriding the comment status — check your active plugins for any comment management plugins.

Bulk Edit Not Saving Comment Status

If the bulk edit does not seem to save, check your user role — you need at minimum the Editor role to bulk edit posts. Also, check for JavaScript errors in the browser console, which could indicate a plugin conflict.

Comments Closed Automatically

WordPress has a built-in setting to close comments after a certain number of days. If comments are being closed automatically on older posts, navigate to Settings > Discussion and look for the option Automatically close comments on posts older than X days. Uncheck it or adjust the number of days to suit your needs.

Frequently Asked Questions

How do I disable WordPress comments on all existing posts at once?

The fastest way is to use WP-CLI with the command wp post list --post_status=publish --post_type=post --format=ids | xargs -d ' ' -I % wp post update % --comment_status=closed. Alternatively, use the bulk edit feature in Posts > All Posts by selecting all posts and setting Comments to "Do not allow." For very large sites, a direct database query or a comment management plugin may be more efficient.

Will disabling comments remove existing comments from my posts?

No. Disabling comments only prevents new comments from being submitted. All previously approved comments remain visible on the post unless you manually delete or unapprove them from the Comments section of your dashboard.

Can I disable comments on pages but keep them on posts?

Yes. You can do this in bulk by going to Pages > All Pages, selecting all pages, using Bulk Edit, and setting Comments to "Do not allow." You can also use a PHP snippet targeting the page post type specifically, or manage each page individually through its editor's Discussion panel.

Does disabling comments affect my site's SEO?

Disabling comments can have a minor SEO impact. Comments often add unique, keyword-rich content to a page, which can help with rankings. However, unmoderated comments can also introduce spammy content. For most sites, the SEO effect of disabling comments is negligible compared to the benefits of reduced spam and faster page load times from fewer database queries.

Managing WordPress comments — whether on a single post, in bulk, or across your entire site — gives you meaningful control over your community and content quality. From the built-in Discussion panel to WP-CLI commands and PHP filters, you now have a complete toolkit to handle any comment scenario. If you would rather skip the manual steps entirely, WP AI Agent is a tool that lets you manage WordPress tasks like enabling or disabling comments simply by describing what you want in plain-language AI chat — no menus or code required.

Ready to manage WordPress with AI?

Get 100,000 tokens free every month. No credit card required.

Get Your Free License Key →

More from the blog