Tips・WordPress settings and upkeep

How to remove or close the comments section

The steps to remove comments cleanly. Covers settings that close both future and existing posts, removing the output in your theme, and the options when you only want to stop spam.

On a site that doesn’t use comments, an empty comments section alone makes things look careless—and left alone, it becomes a destination for spam. Here are the steps to remove them reliably, ordered from least invasive.

1. Close future posts (settings)

  1. Open “Settings” → “Discussion
  2. UntickAllow people to submit comments on new posts
  3. Save

Now posts you create from here on start with comments closed. It has no effect on posts already published—that’s the first stumbling block.

2. Close existing posts in bulk

  1. Open “Posts” → the posts list
  2. Increase the per-page count at the top and select all (the checkbox)
  3. Bulk actions” → “Edit” → “Apply”
  4. Set “Comments” to “Do not allow” and press “Update”

Static pages and custom post types can be changed the same way. With a lot of content, repeat it page by page.

3. Remove the output in your theme

comments_template() in your templates is the call that outputs the comments section.

<?php comments_template(); ?>   ← delete this line (or comment it out)

In a theme you built yourself, deleting it is fine. With a distributed theme, override single.php in a child theme (so it stays gone through theme updates).

TipsHow to build a child theme (minimal setup)How to override templates in a child theme

When you want it conditionally, this is the clean way to write it.

<?php if (comments_open() || get_comments_number()) : ?>
  <?php comments_template(); ?>
<?php endif; ?>

This shows it only when “comments are open, or there are already comments.”

4. Disable the comment feature entirely (in code)

To remove it from the admin screen as well and never use it, this is the route.

// 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');
    }
  }
});

// close existing comments across the board
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// don't display existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// hide Comments from the admin menu
add_action('admin_menu', function () {
  remove_menu_page('edit-comments.php');
});

__return_false and __return_empty_array are functions WordPress provides that “always return false / an empty array.” You can hand them to a filter without writing a function yourself.

TipsAn introduction to WordPress hooks (add_action and add_filter)How add_filter works (priority and arguments)

Keeping comments: stopping only the spam

If you want comments as a feature, anti-spam measures work in this order.

  1. Turn on “Comment must be manually approved” (“Settings” → “Discussion”)—a person decides what gets published
  2. Activate an anti-spam plugin (including the one bundled with WordPress)
  3. Hold comments containing links for moderation (“Comment Moderation” on the same settings screen)
  4. Close comments on old posts automatically—“Automatically close comments on posts older than N days”

Manual approval alone prevents almost every incident of spam being published. Turning that on is the shortest route.

Turn off trackbacks and pingbacks too

They’re an old mechanism that now functions mostly as a spam entry point.

  • Untick “Allow link notifications from other blogs (pingbacks and trackbacks)” under “Settings” → “Discussion”
  • For existing posts, use the bulk edit above to set pings to not allowed as well

Checklist when comments won’t go away

  1. Per-post settings—the “Discussion” panel in the editing screen (if it’s hidden, reveal it via ”⋮” → “Preferences” → Panels)
  2. The theme’s call—is comments_template() still in single.php, page.php or content-*.php?
  3. Plugins—is a comment-related plugin outputting its own?
  4. Cache—clear it and check again

Summary

  1. Close future posts under Settings → Discussion, and existing posts with a bulk edit
  2. To remove the display itself, take out comments_template() from the template (in a child theme for distributed themes)
  3. To never use it at all, disable it with remove_post_type_support plus the comments_open filter
  4. If you do use comments, turning on manual approval is the shortest anti-spam route

Closing off features you don’t use cleans up both the look and the day-to-day running of the site.

FAQ

How do I remove comments entirely?
Under "Settings" → "Discussion," untick "Allow people to submit comments on new posts" and future posts are closed. For posts already published, use bulk edit in the posts list to set comments to "Do not allow." Removing the comments_template() call in your theme removes the display itself.
I changed the setting but the comments section is still there.
Existing posts have their own setting saved. In the posts list, select all → Bulk actions → Edit → set Comments to "Do not allow" to change them all at once. If a box still remains, your theme is calling comments_template() unconditionally.
Comments appear on static pages too.
Static pages can have comments as well. Turn them off in the individual editing screen (the "Discussion" panel), or remove comment support for pages in functions.php.
I want to keep comments but stop the spam.
Turning on "Comment must be manually approved" under "Settings" → "Discussion" is the most reliable move. Alongside it, activate a standard anti-spam plugin and configure automatic holding based on link count.