Advertisements

get_id_from_blogname

Definition:
function get_id_from_blogname( $name ) {}

Given a blog’s (subdomain or directory) name, retrieve it’s id.

Parameters

  • string $name

Return values

returns:A blog id

Source code

function get_id_from_blogname( $name ) {

	global $wpdb, $current_site;

	$blog_id = wp_cache_get( 'get_id_from_blogname_' . $name, 'blog-details' );

	if ( $blog_id )

		return $blog_id;



	if ( is_subdomain_install() ) {

		$domain = $name . '.' . $current_site->domain;

		$path = $current_site->path;

	} else {

		$domain = $current_site->domain;

		$path = $current_site->path . $name . '/';

	}

	$blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );

1420

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: