Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.