Warning: This function has been deprecated. Use wp_insert_site() instead.

insert_blog() WordPress Function

The insert_blog() function is used to add a new blog to the WordPress database. The function takes two arguments: the name of the blog and the URL of the blog. The function will return the new blog's ID if the blog is successfully added to the database. Otherwise, the function will return an error.

insert_blog( string $domain, string $path, int $site_id ) #

Store basic site info in the blogs table.


Description

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.

Top ↑

See also


Top ↑

Parameters

$domain

(string)(Required)The domain of the new site.

$path

(string)(Required)The path of the new site.

$site_id

(int)(Required)Unless you're running a multi-network install, be sure to set this value to 1.


Top ↑

Return

(int|false) The ID of the new row


Top ↑

Source

File: wp-includes/ms-deprecated.php

function insert_blog($domain, $path, $site_id) {
	_deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );

	$data = array(
		'domain'  => $domain,
		'path'    => $path,
		'site_id' => $site_id,
	);

	$site_id = wp_insert_site( $data );
	if ( is_wp_error( $site_id ) ) {
		return false;
	}

	clean_blog_cache( $site_id );

	return $site_id;
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Use wp_insert_site()
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.