WordPress.org

Ready to get started?Download WordPress

Codex

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

Difference between revisions of "Function Reference/get blog id from url"

(Include information about the function)
 
(No difference)

Latest revision as of 15:18, 17 December 2012

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