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)
- Open “Settings” → “Discussion”
- Untick “Allow people to submit comments on new posts”
- 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
- Open “Posts” → the posts list
- Increase the per-page count at the top and select all (the checkbox)
- “Bulk actions” → “Edit” → “Apply”
- 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).
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.
Keeping comments: stopping only the spam
If you want comments as a feature, anti-spam measures work in this order.
- Turn on “Comment must be manually approved” (“Settings” → “Discussion”)—a person decides what gets published
- Activate an anti-spam plugin (including the one bundled with WordPress)
- Hold comments containing links for moderation (“Comment Moderation” on the same settings screen)
- 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
- Per-post settings—the “Discussion” panel in the editing screen (if it’s hidden, reveal it via ”⋮” → “Preferences” → Panels)
- The theme’s call—is
comments_template()still insingle.php,page.phporcontent-*.php? - Plugins—is a comment-related plugin outputting its own?
- Cache—clear it and check again
Summary
- Close future posts under Settings → Discussion, and existing posts with a bulk edit
- To remove the display itself, take out
comments_template()from the template (in a child theme for distributed themes) - To never use it at all, disable it with
remove_post_type_supportplus thecomments_openfilter - 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.