# Copy Settings From a Template Site to New Sites

> Copies chosen options, such as Customizer settings, the site icon and reading settings, from a template site onto every new site.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: new-site, template, clone
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-new-site-clone-template-options/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

$wpide_template_id = 0; // Blog ID of the template site (0 = off until you set it).
$wpide_options     = array( 'blogdescription', 'posts_per_page', 'date_format', 'time_format', 'timezone_string', 'permalink_structure', 'default_comment_status' );

add_action( 'wp_initialize_site', function ( $site ) use ( $wpide_template_id, $wpide_options ) {
    if ( ! $wpide_template_id || (int) $site->blog_id === (int) $wpide_template_id || ! get_site( $wpide_template_id ) ) {
        return;
    }

    switch_to_blog( $wpide_template_id );
    $values     = array();
    foreach ( $wpide_options as $option ) {
        $values[ $option ] = get_option( $option );
    }
    $stylesheet = get_option( 'stylesheet' );
    $template   = get_option( 'template' );
    $mods       = get_option( 'theme_mods_' . $stylesheet );
    restore_current_blog();

    switch_to_blog( $site->blog_id );
    foreach ( $values as $option => $value ) {
        if ( false !== $value ) {
            update_option( $option, $value );
        }
    }
    if ( $stylesheet && wp_get_theme( $stylesheet )->exists() ) {
        update_option( 'template', $template );
        update_option( 'stylesheet', $stylesheet );
        if ( is_array( $mods ) ) {
            unset( $mods['custom_logo'], $mods['nav_menu_locations'], $mods['custom_css_post_id'] );
            update_option( 'theme_mods_' . $stylesheet, $mods );
        }
    }
    delete_option( 'rewrite_rules' );
    restore_current_blog();
}, 220 );
```

## Notes

Set $wpide_template_id to the blog ID of your template site. Options that point to posts or media (like page_on_front) are not copied because IDs differ between sites.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Copy Settings From a Template Site to New Sites" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
