WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get blog id from url

Description

Get a blog's numeric ID from its URL.

Usage

<?php get_blog_id_from_url( $domain, $path ); ?>

Parameters

$domain
(string) (required) Blog domain.
Default: None
$path
(string) (optional) Blog path.
Default: "/"

Return Value

(integer) 
0 if no blog found, otherwise the ID of the matching blog.

Examples

<?php 
// For subdirectory installs
$blog_id = get_blog_id_from_url("example.com", "/blog1/");

// For subdomain installs
$blog_id = get_blog_id_from_url("blog1.example.com");
?>

Default Usage

Change Log

Source File

get_blog_id_from_url() is located in wp-includes/ms-functions.php

Related