Disable Comments for Pages in WordPress

I usually don’t have customers for websites that will like to have comments on their pages.
Who does?! Comments are good for blog posts.

WordPress checks off the “allow comments” box by default.
In order to have new pages without that feature, you’ll need to add the code below in the functions.php file, at the end.


function default_comments_off( $data ) {
if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
$data['comment_status'] = 0;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_off' );

That’s it, next time you’ll create a new page, the “allow comments” box will be unchecked. Have fun!