skip to Main Content

If you get a lot of spam comments but dont want to install a plugin or delete/hide any existing comments manually for all post types then all you have to do is add this function into your current’s theme functions.php file.

function updated_disable_comments_post_types_support() {
   $types = get_post_types();
   foreach ($types as $type) {
      if(post_type_supports($type, 'comments')) {
         remove_post_type_support($type, 'comments');
         remove_post_type_support($type, 'trackbacks');
      }
   }
}
add_action('admin_init', 'disable_comments_post_types_support');


function disable_comments_hide_existing_comments($comments) {
   $comments = array();
   return $comments;
}
add_filter('comments_array', 'disable_comments_hide_existing_comments', 10, 2);

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

 

Back To Top