Due to WordPress being such a popular CMS, the WP comment system is constantly under attack by spammers. This can make it a full time job just to manage the huge influx of spam comments each and every day.
For a lot of websites, comments aren’t needed at all. Other people just can’t be bothered with the time it takes to manage them all. There is also a point to be made that the often unrelated text in the comments dilutes the SEO of your post.
Anyway, if you are one of the people who would like to turn off WordPress comments by default site wide, below snippet is for you. Just paste it into your (child) theme’s functions.php and your comment troubles have vanished.
// Close comments by default (freezeweb.net)
function prefix_comments_open( $open, $post_id ) {
$post = get_post( $post_id );
$open = false;
return $open;
}
add_filter( 'comments_open', 'prefix_comments_open', 10, 2 );
It’s good practice to change ‘prefix’ with your site name to make sure all functions are 100% unique.