WordPress multi-site access to current blog info _ PHP Tutorial

Source: Internet
Author: User
Tags multisite subdomain name
The WordPress multi-site obtains the current blog information. Www. utubon. com1495wordpress-multisite-get-current-bolg-infoglobal $ current_blog; The Returned result is: stdClassObject ([blog_id] 3 [site_id] 1 [domain] demo. utu http://www.utubon.com/1495/wordpress-multisite-get-current-bolg-info

global $current_blog;

The returned result is:

stdClass Object(    [blog_id] => 3    [site_id] => 1    [domain] => demo.utubon.com    [path] => /neighborhood/    [registered] => 2013-08-01 10:31:03    [last_updated] => 2013-08-01 02:31:03    [public] => 1    [archived] => 0    [mature] => 0    [spam] => 0    [deleted] => 0    [lang_id] => 0)

You can also useGet_blog_detailsFunction:

$current_blog = get_blog_details();

The returned result is:

StdClass Object ([blog_id] => 3 [site_id] => 1 [domain] => demo.utubon.com [path] =>/neighborhood/[registered] => 2013-08-01 10:31:03 [last_updated] => 02:31:03 [public] => 1 [archived] => 0 [mature] => 0 [spam] => 0 [deleted] => 0 [lang_id] => 0 [blogname] => Neighborhood [siteurl] => http://demo.utubon.com/neighborhood [post_count] =>) // more information than global $ current_blog

This basically satisfies our needs. However, there is another method that is relatively difficult to use.Get_blog_id_from_urlFunction. If you use sub-directories for multiple sites, use:

$blog_id = get_blog_id_from_url("example.com", "/blog1/");

If you are using a subdomain name, use:

$blog_id = get_blog_id_from_url("blog1.example.com");

The above parameters can be used$ _ SERVER ['server _ name']And$ _ SERVER ["REQUEST_URI"].

After obtaining $ blog_id, you can easily perform various tasks.

Http://www.bkjia.com/PHPjc/738537.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/738537.htmlTechArticlehttp://www.utubon.com/1495/wordpress-multisite-get-current-bolg-info global $ current_blog; its returned result is: stdClass Object ([blog_id] = 3 [site_id] = 1 [domain] = demo. utu...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.