Default Settings for New Network Sites
Applies your preferred timezone, date and time formats, week start, permalink structure and language to every site created on the network.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
$wpide_defaults = array( // Option name => value applied to each new site.
'timezone_string' => 'Europe/London',
'date_format' => 'j F Y',
'time_format' => 'H:i',
'start_of_week' => 1,
'permalink_structure' => '/%postname%/',
'WPLANG' => '', // Empty = English (US), or a locale such as fr_FR.
);
add_action( 'wp_initialize_site', function ( $site ) use ( $wpide_defaults ) {
switch_to_blog( $site->blog_id );
foreach ( $wpide_defaults as $option => $value ) {
update_option( $option, $value );
}
if ( isset( $wpide_defaults['permalink_structure'] ) ) {
delete_option( 'rewrite_rules' ); // Rebuilt on the site's first request.
}
restore_current_blog();
}, 200 );
Notes
Edit $wpide_defaults; any option name works. Existing sites are not changed.
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.