Hide New Network Sites From Search Engines
Sets every newly created site to "Discourage search engines" so half-built sites are not indexed; site owners switch it off when they launch.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_action( 'wp_initialize_site', function ( $site ) {
update_blog_status( $site->blog_id, 'public', 0 );
switch_to_blog( $site->blog_id );
update_option( 'blog_public', 0 );
restore_current_blog();
}, 200 );
Notes
Pair it with the "Search engines" column snippet to see which sites still need switching on.
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.