Title: make_site_theme_from_default
Published: April 25, 2014
Last modified: May 20, 2026

---

# make_site_theme_from_default( string $theme_name, string $template ): void|false

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#wp--skip-link--target)

Creates a site theme from the default theme.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#description)󠁿

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#parameters)󠁿

 `$theme_name`stringrequired

The name of the theme.

`$template`stringrequired

The directory name of the theme.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#return)󠁿

 void|false

## 󠀁[Source](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#source)󠁿

    ```php
    function make_site_theme_from_default( $theme_name, $template ) {
    	$site_dir    = WP_CONTENT_DIR . "/themes/$template";
    	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;

    	/*
    	 * Copy files from the default theme to the site theme.
    	 * $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
    	 */

    	$theme_dir = @opendir( $default_dir );
    	if ( $theme_dir ) {
    		while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) {
    			if ( is_dir( "$default_dir/$theme_file" ) ) {
    				continue;
    			}

    			if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) {
    				return;
    			}

    			chmod( "$site_dir/$theme_file", 0777 );
    		}

    		closedir( $theme_dir );
    	}

    	// Rewrite the theme header.
    	$stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) );
    	if ( $stylelines ) {
    		$f = fopen( "$site_dir/style.css", 'w' );

    		$headers = array(
    			'Theme Name:'  => $theme_name,
    			'Theme URI:'   => __get_option( 'url' ),
    			'Description:' => 'Your theme.',
    			'Version:'     => '1',
    			'Author:'      => 'You',
    		);

    		foreach ( $stylelines as $line ) {
    			foreach ( $headers as $header => $value ) {
    				if ( str_contains( $line, $header ) ) {
    					$line = $header . ' ' . $value;
    					break;
    				}
    			}

    			fwrite( $f, $line . "\n" );
    		}

    		fclose( $f );
    	}

    	// Copy the images.
    	umask( 0 );
    	if ( ! mkdir( "$site_dir/images", 0777 ) ) {
    		return false;
    	}

    	$images_dir = @opendir( "$default_dir/images" );
    	if ( $images_dir ) {
    		while ( ( $image = readdir( $images_dir ) ) !== false ) {
    			if ( is_dir( "$default_dir/images/$image" ) ) {
    				continue;
    			}

    			if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) {
    				return;
    			}

    			chmod( "$site_dir/images/$image", 0777 );
    		}

    		closedir( $images_dir );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/upgrade.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/upgrade.php#L3516)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/upgrade.php#L3516-L3591)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#related)󠁿

| Used by | Description | 
| [make_site_theme()](https://developer.wordpress.org/reference/functions/make_site_theme/)`wp-admin/includes/upgrade.php` |

Creates a site theme.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/make_site_theme_from_default/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fmake_site_theme_from_default%2F)
before being able to contribute a note or feedback.