get_current_blog_id()WP 3.1.0

Retrieve the current site (blog) ID.

The function uses the global variable $blog_id.

Works early in WordPress loading, even before the SHORTINIT constant.

About the differences between websites and blogs in MU read here

Used By: is_main_site()
1 time — 0.000018 sec (very fast) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.2, WP 4.7.5

No Hooks.

Return

Int. Site ID.

Usage

get_current_blog_id();

Examples

0

#1 Get the ID of the current blog:

$blog_id = get_current_blog_id();

Notes

  • Global. Int. $blog_id

Changelog

Since 3.1.0 Introduced.

get_current_blog_id() code WP 6.5.2

function get_current_blog_id() {
	global $blog_id;

	return absint( $blog_id );
}