Turn Off Comments on New Network Sites
Creates every new site with comments, pingbacks and trackbacks switched off by default, for networks of brochure or business sites.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_action( 'wp_initialize_site', function ( $site ) {
switch_to_blog( $site->blog_id );
update_option( 'default_comment_status', 'closed' );
update_option( 'default_ping_status', 'closed' );
update_option( 'default_pingback_flag', 0 );
restore_current_blog();
}, 200 );
Notes
Site owners can still turn comments on in Settings > Discussion.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.