WordPress Q&As Logo
WordPress Q&As Part of the Q&A Network
Q&A Logo

What’s the safest way to disable comments site-wide in WordPress?

Asked on Aug 28, 2025

Answer

To safely disable comments site-wide in WordPress, you can use a plugin or add custom code to your theme's functions.php file. This ensures that comments are disabled across all posts, pages, and custom post types.
<!-- BEGIN COPY / PASTE -->
    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');

    function disable_comments_status() {
      return false;
    }
    add_filter('comments_open', 'disable_comments_status', 20, 2);
    add_filter('pings_open', 'disable_comments_status', 20, 2);

    function disable_comments_admin_menu() {
      remove_menu_page('edit-comments.php');
    }
    add_action('admin_menu', 'disable_comments_admin_menu');
    <!-- END COPY / PASTE -->
Additional Comment:
  • This code removes comment support from all post types and closes comments and pings on all posts.
  • It also removes the Comments menu from the WordPress admin dashboard.
  • For a plugin solution, consider using the "Disable Comments" plugin, which provides a user-friendly interface.
  • Always back up your site before making changes to theme files or installing new plugins.
✅ Answered with WordPress best practices.

← Back to All Questions
The Q&A Network