WordPress at a glance
function is not described

insert_blog() WP 3.0.0

Store basic site info in the blogs table.

This function creates a row in the wp_blogs table and returns the new blog's ID. It is the first step in creating a new blog.

  • Global. wpdb. $wpdb WordPress database abstraction object.

No Hooks.


Int/false. The ID of the new row


insert_blog( $domain, $path, $network_id );
$domain(string) (required)
The domain of the new site.
$path(string) (required)
The path of the new site.
$network_id(int) (required)
Unless you're running a multi-network installation, be sure to set this value to 1.

Code of insert blog: wp-includes/ms-functions.php VER 5.0.3

function insert_blog($domain, $path, $network_id) {
	global $wpdb;

	$path = trailingslashit($path);
	$network_id = (int) $network_id;

	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
	if ( ! $result )
		return false;

	$blog_id = $wpdb->insert_id;
	clean_blog_cache( $blog_id );

	wp_maybe_update_network_site_counts( $network_id );

	return $blog_id;