Quick‑start summary
- Create a new folder inside wp‑content/plugins/, e.g. disable‑all‑comments.
- Create a file called disable-all-comments.php inside that folder and paste the code that follows.
- Visit Plugins → Installed Plugins in your dashboard and click Activate.
- Celebrate! 🎉 Comments, pingbacks, and trackbacks are now globally off. (You can deactivate the plugin any time to restore default behaviour.)
The plugin code
<?php
/**
* Plugin Name: Disable All Comments
* Description: Completely disables comments, pingbacks, and trackbacks everywhere—no settings page needed.
* Version: 1.0.0
* Author: You 🤘
* License: GPL‑2.0‑or‑later
* Text Domain: disable-all-comments
*/
/*
|————————————————————————–
| 1. Stop comments & pings from being opened
|————————————————————————–
*/
add_filter( ‘comments_open’, ‘__return_false’, 20, 2 );
add_filter( ‘pings_open’, ‘__return_false’, 20, 2 );
/*
|————————————————————————–
| 2. Hide existing comments from front‑end templates
|————————————————————————–
*/
add_filter( ‘comments_array’, ‘__return_empty_array’, 10, 2 );
/*
|————————————————————————–
| 3. Strip comment support from all post types
|————————————————————————–
*/
function dac_remove_comment_support() {
foreach ( get_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( ‘init’, ‘dac_remove_comment_support’, 99 );
/*
|————————————————————————–
| 4. Clean up the admin UI
|————————————————————————–
*/
function dac_admin_menu_cleanup() {
remove_menu_page( ‘edit-comments.php’ ); // Sidebar “Comments”
}
add_action( ‘admin_menu’, ‘dac_admin_menu_cleanup’ );
function dac_admin_bar_cleanup() {
if ( is_admin_bar_showing() ) {
remove_action( ‘admin_bar_menu’, ‘wp_admin_bar_comments_menu’, 60 );
}
}
add_action( ‘init’, ‘dac_admin_bar_cleanup’ );
/*
|————————————————————————–
| 5. Disable comment‑related REST & feeds (optional hard block)
|————————————————————————–
*/
add_filter( ‘rest_endpoints’, function ( $endpoints ) {
unset( $endpoints[‘/wp/v2/comments’] );
return $endpoints;
} );
add_filter( ‘feed_links_show_comments_feed’, ‘__return_false’ );
How it works
| Step | Hook / Function | What it does | Key reference |
| 1 | comments_open & pings_open filters | Forces both to always return false, so WP thinks comments are closed everywhere. | WordPress Developer docs on comments_open() |
| 2 | comments_array filter | Returns an empty array, hiding any old comments from templates without deleting them. | WePlugins tutorial on using comment filters |
| 3 | remove_post_type_support() in init | Strips the “Discussion” metabox & comment support from all post types. | WPBeginner guide to fully disabling comments |
| 4 | admin_menu & admin‑bar hooks | Removes sidebar “Comments” and top‑bar bubble for a cleaner UI. | Kinsta overview of Disable Comments plugin UI effects |
| 5 | REST & feed filters | Blocks comment endpoints & comment RSS feeds for good measure. | Disable Comments plugin advanced config notes |
Installation & activation details
- ZIP and upload via Plugins → Add New → Upload, or FTP/SFTP the folder directly.
- Network sites? Activate network‑wide for multisite or per‑site as desired; the hooks fire within each site context.
- Custom post types are covered automatically because the loop in dac_remove_comment_support() enumerates every registered type.
FAQs
Will this delete existing comments?
No. It merely hides them. Deactivate the plugin and every historical comment instantly reappears.
Is it safe for future WP versions?
The plugin relies solely on long‑standing core hooks (comments_open, admin_bar_menu, etc.) that have existed since WordPress 2.7+. The same pattern is used by the popular “Disable Comments” plugin with 1 M+ installs.
Can I selectively allow comments on certain post types instead?
For granular control, keep this plugin off and use a full‑featured settings plugin such as “Disable Comments” (free) instead.
Go forth and publish—comment‑free! 🚀
Enjoy the peace of mind of a totally silent comment section while you focus on creating amazing content and innovations.